@@ -74,7 +74,8 @@ import Text.PrettyPrint ((<>), (<+>))
7474
7575import qualified Language.Haskell.Extension as Extension (deprecatedExtensions )
7676import Language.Haskell.Extension
77- ( Language (UnknownLanguage ), knownLanguages , Extension (.. ), KnownExtension (.. ) )
77+ ( Language (UnknownLanguage ), knownLanguages
78+ , Extension (.. ), KnownExtension (.. ) )
7879import System.FilePath
7980 ( (</>) , takeExtension , isRelative , isAbsolute
8081 , splitDirectories , splitPath )
@@ -120,7 +121,8 @@ check :: Bool -> PackageCheck -> Maybe PackageCheck
120121check False _ = Nothing
121122check True pc = Just pc
122123
123- checkSpecVersion :: PackageDescription -> [Int ] -> Bool -> PackageCheck -> Maybe PackageCheck
124+ checkSpecVersion :: PackageDescription -> [Int ] -> Bool -> PackageCheck
125+ -> Maybe PackageCheck
124126checkSpecVersion pkg specver cond pc
125127 | specVersion pkg >= Version specver [] = Nothing
126128 | otherwise = check cond pc
@@ -190,7 +192,8 @@ checkSanity pkg =
190192 ++ " . The name of every executable, test suite, and benchmark section in"
191193 ++ " the package must be unique."
192194 ]
193- -- TODO: check for name clashes case insensitively: windows file systems cannot cope.
195+ -- TODO: check for name clashes case insensitively: windows file systems cannot
196+ -- cope.
194197
195198 ++ maybe [] (checkLibrary pkg) (library pkg)
196199 ++ concatMap (checkExecutable pkg) (executables pkg)
@@ -598,9 +601,11 @@ checkGhcOptions pkg =
598601 " 'ghc-options: -fhpc' is not appropriate for a distributed package."
599602
600603 -- -dynamic is not a debug flag
601- , check (any (\ opt -> " -d" `isPrefixOf` opt && opt /= " -dynamic" ) all_ghc_options) $
604+ , check (any (\ opt -> " -d" `isPrefixOf` opt && opt /= " -dynamic" )
605+ all_ghc_options) $
602606 PackageDistInexcusable $
603- " 'ghc-options: -d*' debug flags are not appropriate for a distributed package."
607+ " 'ghc-options: -d*' debug flags are not appropriate "
608+ ++ " for a distributed package."
604609
605610 , checkFlags [" -prof" ] $
606611 PackageBuildWarning $
@@ -610,37 +615,43 @@ checkGhcOptions pkg =
610615
611616 , checkFlags [" -o" ] $
612617 PackageBuildWarning $
613- " 'ghc-options: -o' is not needed. The output files are named automatically."
618+ " 'ghc-options: -o' is not needed. "
619+ ++ " The output files are named automatically."
614620
615621 , checkFlags [" -hide-package" ] $
616622 PackageBuildWarning $
617- " 'ghc-options: -hide-package' is never needed. Cabal hides all packages."
623+ " 'ghc-options: -hide-package' is never needed. "
624+ ++ " Cabal hides all packages."
618625
619626 , checkFlags [" --make" ] $
620627 PackageBuildWarning $
621- " 'ghc-options: --make' is never needed. Cabal uses this automatically."
628+ " 'ghc-options: --make' is never needed. Cabal uses this automatically."
622629
623630 , checkFlags [" -main-is" ] $
624631 PackageDistSuspicious $
625- " 'ghc-options: -main-is' is not portable."
632+ " 'ghc-options: -main-is' is not portable."
626633
627634 , checkFlags [" -O0" , " -Onot" ] $
628635 PackageDistSuspicious $
629- " 'ghc-options: -O0' is not needed. Use the --disable-optimization configure flag."
636+ " 'ghc-options: -O0' is not needed. "
637+ ++ " Use the --disable-optimization configure flag."
630638
631639 , checkFlags [ " -O" , " -O1" ] $
632640 PackageDistInexcusable $
633- " 'ghc-options: -O' is not needed. Cabal automatically adds the '-O' flag. "
634- ++ " Setting it yourself interferes with the --disable-optimization flag."
641+ " 'ghc-options: -O' is not needed. "
642+ ++ " Cabal automatically adds the '-O' flag. "
643+ ++ " Setting it yourself interferes with the --disable-optimization flag."
635644
636645 , checkFlags [" -O2" ] $
637646 PackageDistSuspicious $
638- " 'ghc-options: -O2' is rarely needed. Check that it is giving a real benefit "
639- ++ " and not just imposing longer compile times on your users."
647+ " 'ghc-options: -O2' is rarely needed. "
648+ ++ " Check that it is giving a real benefit "
649+ ++ " and not just imposing longer compile times on your users."
640650
641651 , checkFlags [" -split-objs" ] $
642652 PackageBuildWarning $
643- " 'ghc-options: -split-objs' is not needed. Use the --enable-split-objs configure flag."
653+ " 'ghc-options: -split-objs' is not needed. "
654+ ++ " Use the --enable-split-objs configure flag."
644655
645656 , checkFlags [" -optl-Wl,-s" , " -optl-s" ] $
646657 PackageDistInexcusable $
@@ -652,7 +663,8 @@ checkGhcOptions pkg =
652663
653664 , checkFlags [" -fglasgow-exts" ] $
654665 PackageDistSuspicious $
655- " Instead of 'ghc-options: -fglasgow-exts' it is preferable to use the 'extensions' field."
666+ " Instead of 'ghc-options: -fglasgow-exts' it is preferable to use "
667+ ++ " the 'extensions' field."
656668
657669 , check (" -threaded" `elem` lib_ghc_options) $
658670 PackageDistSuspicious $
@@ -695,40 +707,43 @@ checkGhcOptions pkg =
695707 checkFlags flags = check (any (`elem` flags) all_ghc_options)
696708
697709 ghcExtension (' -' : ' f' : name) = case name of
698- " allow-overlapping-instances" -> Just ( EnableExtension OverlappingInstances )
699- " no-allow-overlapping-instances" -> Just ( DisableExtension OverlappingInstances )
700- " th" -> Just ( EnableExtension TemplateHaskell )
701- " no-th" -> Just ( DisableExtension TemplateHaskell )
702- " ffi" -> Just ( EnableExtension ForeignFunctionInterface )
703- " no-ffi" -> Just ( DisableExtension ForeignFunctionInterface )
704- " fi" -> Just ( EnableExtension ForeignFunctionInterface )
705- " no-fi" -> Just ( DisableExtension ForeignFunctionInterface )
706- " monomorphism-restriction" -> Just ( EnableExtension MonomorphismRestriction )
707- " no-monomorphism-restriction" -> Just ( DisableExtension MonomorphismRestriction )
708- " mono-pat-binds" -> Just ( EnableExtension MonoPatBinds )
709- " no-mono-pat-binds" -> Just ( DisableExtension MonoPatBinds )
710- " allow-undecidable-instances" -> Just ( EnableExtension UndecidableInstances )
711- " no-allow-undecidable-instances" -> Just ( DisableExtension UndecidableInstances )
712- " allow-incoherent-instances" -> Just ( EnableExtension IncoherentInstances )
713- " no-allow-incoherent-instances" -> Just ( DisableExtension IncoherentInstances )
714- " arrows" -> Just ( EnableExtension Arrows )
715- " no-arrows" -> Just ( DisableExtension Arrows )
716- " generics" -> Just ( EnableExtension Generics )
717- " no-generics" -> Just ( DisableExtension Generics )
718- " implicit-prelude" -> Just ( EnableExtension ImplicitPrelude )
719- " no-implicit-prelude" -> Just ( DisableExtension ImplicitPrelude )
720- " implicit-params" -> Just ( EnableExtension ImplicitParams )
721- " no-implicit-params" -> Just ( DisableExtension ImplicitParams )
722- " bang-patterns" -> Just ( EnableExtension BangPatterns )
723- " no-bang-patterns" -> Just ( DisableExtension BangPatterns )
724- " scoped-type-variables" -> Just ( EnableExtension ScopedTypeVariables )
725- " no-scoped-type-variables" -> Just ( DisableExtension ScopedTypeVariables )
726- " extended-default-rules" -> Just ( EnableExtension ExtendedDefaultRules )
727- " no-extended-default-rules" -> Just ( DisableExtension ExtendedDefaultRules )
710+ " allow-overlapping-instances" -> enable OverlappingInstances
711+ " no-allow-overlapping-instances" -> disable OverlappingInstances
712+ " th" -> enable TemplateHaskell
713+ " no-th" -> disable TemplateHaskell
714+ " ffi" -> enable ForeignFunctionInterface
715+ " no-ffi" -> disable ForeignFunctionInterface
716+ " fi" -> enable ForeignFunctionInterface
717+ " no-fi" -> disable ForeignFunctionInterface
718+ " monomorphism-restriction" -> enable MonomorphismRestriction
719+ " no-monomorphism-restriction" -> disable MonomorphismRestriction
720+ " mono-pat-binds" -> enable MonoPatBinds
721+ " no-mono-pat-binds" -> disable MonoPatBinds
722+ " allow-undecidable-instances" -> enable UndecidableInstances
723+ " no-allow-undecidable-instances" -> disable UndecidableInstances
724+ " allow-incoherent-instances" -> enable IncoherentInstances
725+ " no-allow-incoherent-instances" -> disable IncoherentInstances
726+ " arrows" -> enable Arrows
727+ " no-arrows" -> disable Arrows
728+ " generics" -> enable Generics
729+ " no-generics" -> disable Generics
730+ " implicit-prelude" -> enable ImplicitPrelude
731+ " no-implicit-prelude" -> disable ImplicitPrelude
732+ " implicit-params" -> enable ImplicitParams
733+ " no-implicit-params" -> disable ImplicitParams
734+ " bang-patterns" -> enable BangPatterns
735+ " no-bang-patterns" -> disable BangPatterns
736+ " scoped-type-variables" -> enable ScopedTypeVariables
737+ " no-scoped-type-variables" -> disable ScopedTypeVariables
738+ " extended-default-rules" -> enable ExtendedDefaultRules
739+ " no-extended-default-rules" -> disable ExtendedDefaultRules
728740 _ -> Nothing
729- ghcExtension " -cpp" = Just ( EnableExtension CPP )
741+ ghcExtension " -cpp" = enable CPP
730742 ghcExtension _ = Nothing
731743
744+ enable e = Just (EnableExtension e)
745+ disable e = Just (DisableExtension e)
746+
732747checkCCOptions :: PackageDescription -> [PackageCheck ]
733748checkCCOptions pkg =
734749 catMaybes [
@@ -906,15 +921,17 @@ checkCabalVersion pkg =
906921 ++ " 'other-languages' field."
907922
908923 -- check use of reexported-modules sections
909- , checkVersion [1 ,21 ] (maybe False (not . null . reexportedModules) (library pkg)) $
924+ , checkVersion [1 ,21 ]
925+ (maybe False (not . null . reexportedModules) (library pkg)) $
910926 PackageDistInexcusable $
911927 " To use the 'reexported-module' field the package needs to specify "
912928 ++ " at least 'cabal-version: >= 1.21'."
913929
914930 -- check use of thinning and renaming
915931 , checkVersion [1 ,21 ] (not (null depsUsingThinningRenamingSyntax)) $
916932 PackageDistInexcusable $
917- " The package uses thinning and renaming in the 'build-depends' field: "
933+ " The package uses "
934+ ++ " thinning and renaming in the 'build-depends' field: "
918935 ++ commaSep (map display depsUsingThinningRenamingSyntax)
919936 ++ " . To use this new syntax, the package needs to specify at least"
920937 ++ " 'cabal-version: >= 1.21'."
@@ -1092,14 +1109,16 @@ checkCabalVersion pkg =
10921109 -- XXX: If the user writes build-depends: foo with (), this is
10931110 -- indistinguishable from build-depends: foo, so there won't be an
10941111 -- error even though there should be
1095- depsUsingThinningRenamingSyntax = [ name
1096- | bi <- allBuildInfo pkg
1097- , (name, rns) <- Map. toList (targetBuildRenaming bi)
1098- , rns /= ModuleRenaming True [] ]
1112+ depsUsingThinningRenamingSyntax =
1113+ [ name
1114+ | bi <- allBuildInfo pkg
1115+ , (name, rns) <- Map. toList (targetBuildRenaming bi)
1116+ , rns /= ModuleRenaming True [] ]
10991117
1100- testedWithUsingWildcardSyntax = [ Dependency (PackageName (display compiler)) vr
1101- | (compiler, vr) <- testedWith pkg
1102- , usesWildcardSyntax vr ]
1118+ testedWithUsingWildcardSyntax =
1119+ [ Dependency (PackageName (display compiler)) vr
1120+ | (compiler, vr) <- testedWith pkg
1121+ , usesWildcardSyntax vr ]
11031122
11041123 usesWildcardSyntax :: VersionRange -> Bool
11051124 usesWildcardSyntax =
@@ -1179,8 +1198,10 @@ displayRawVersionRange =
11791198 (\ v -> (Disp. text " >=" <> disp v , 0 ))
11801199 (\ v -> (Disp. text " <=" <> disp v , 0 ))
11811200 (\ v _ -> (Disp. text " ==" <> dispWild v , 0 ))
1182- (\ (r1, p1) (r2, p2) -> (punct 2 p1 r1 <+> Disp. text " ||" <+> punct 2 p2 r2 , 2 ))
1183- (\ (r1, p1) (r2, p2) -> (punct 1 p1 r1 <+> Disp. text " &&" <+> punct 1 p2 r2 , 1 ))
1201+ (\ (r1, p1) (r2, p2) ->
1202+ (punct 2 p1 r1 <+> Disp. text " ||" <+> punct 2 p2 r2 , 2 ))
1203+ (\ (r1, p1) (r2, p2) ->
1204+ (punct 1 p1 r1 <+> Disp. text " &&" <+> punct 1 p2 r2 , 1 ))
11841205 (\ (r, _ ) -> (Disp. parens r, 0 )) -- parens
11851206
11861207 where
0 commit comments