Skip to content

Commit

Permalink
Don't warn about 'prepositive-qualified-module' in Paths_pkgs
Browse files Browse the repository at this point in the history
Enabling '-Wprepositive-qualified-module' in a project leads to warnings
when used in combination with Cabal's Paths_* feature. Given that this
is code outside of a user's control, this warning should be disabled
locally.
  • Loading branch information
martijnbastiaan authored and mergify[bot] committed Aug 10, 2022
1 parent dd312ec commit 921bf6b
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ render z_root = execWriter $ do
return ()
else do
return ()
if (zSupportsCpp z_root)
then do
tell "#if __GLASGOW_HASKELL__ >= 810\n"
tell "{-# OPTIONS_GHC -fno-warn-prepositive-qualified-module #-}\n"
tell "#endif\n"
return ()
else do
return ()
tell "{-# OPTIONS_GHC -fno-warn-missing-import-lists #-}\n"
tell "{-# OPTIONS_GHC -w #-}\n"
tell "module Paths_"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Main where

main :: IO ()
main = return ()
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: PathsModule
version: 0.1
license: BSD3
author: Martijn Bastiaan
stability: stable
category: PackageTests
build-type: Simple
Cabal-version: >= 1.2

description:
Check that the generated paths module compiles.

Executable TestPathsModule
main-is: Main.hs
if impl(ghc >= 8.10.0)
ghc-options: -Werror -fwarn-prepositive-qualified-module
other-modules: Paths_PathsModule
build-depends: base
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Setup configure
Configuring PathsModule-0.1...
# Setup build
Preprocessing executable 'TestPathsModule' for PathsModule-0.1..
Building executable 'TestPathsModule' for PathsModule-0.1..
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Setup configure
Configuring PathsModule-0.1...
# Setup build
Preprocessing executable 'TestPathsModule' for PathsModule-0.1..
Building executable 'TestPathsModule' for PathsModule-0.1..
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Test.Cabal.Prelude
-- Test that Paths module is generated and available for executables.
main = setupAndCabalTest $ setup_build []

5 changes: 5 additions & 0 deletions templates/Paths_pkg.template.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
{% if not absolute %}
{-# LANGUAGE ForeignFunctionInterface #-}
{% endif %}
{% if supportsCpp %}
#if __GLASGOW_HASKELL__ >= 810
{-# OPTIONS_GHC -fno-warn-prepositive-qualified-module #-}
#endif
{% endif %}
{-# OPTIONS_GHC -fno-warn-missing-import-lists #-}
{-# OPTIONS_GHC -w #-}
module Paths_{{ manglePkgName packageName }} (
Expand Down

0 comments on commit 921bf6b

Please sign in to comment.