@@ -74,7 +74,8 @@ import Text.PrettyPrint ((<>), (<+>))
74
74
75
75
import qualified Language.Haskell.Extension as Extension (deprecatedExtensions )
76
76
import Language.Haskell.Extension
77
- ( Language (UnknownLanguage ), knownLanguages , Extension (.. ), KnownExtension (.. ) )
77
+ ( Language (UnknownLanguage ), knownLanguages
78
+ , Extension (.. ), KnownExtension (.. ) )
78
79
import System.FilePath
79
80
( (</>) , takeExtension , isRelative , isAbsolute
80
81
, splitDirectories , splitPath )
@@ -120,7 +121,8 @@ check :: Bool -> PackageCheck -> Maybe PackageCheck
120
121
check False _ = Nothing
121
122
check True pc = Just pc
122
123
123
- checkSpecVersion :: PackageDescription -> [Int ] -> Bool -> PackageCheck -> Maybe PackageCheck
124
+ checkSpecVersion :: PackageDescription -> [Int ] -> Bool -> PackageCheck
125
+ -> Maybe PackageCheck
124
126
checkSpecVersion pkg specver cond pc
125
127
| specVersion pkg >= Version specver [] = Nothing
126
128
| otherwise = check cond pc
@@ -190,7 +192,8 @@ checkSanity pkg =
190
192
++ " . The name of every executable, test suite, and benchmark section in"
191
193
++ " the package must be unique."
192
194
]
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.
194
197
195
198
++ maybe [] (checkLibrary pkg) (library pkg)
196
199
++ concatMap (checkExecutable pkg) (executables pkg)
@@ -598,9 +601,11 @@ checkGhcOptions pkg =
598
601
" 'ghc-options: -fhpc' is not appropriate for a distributed package."
599
602
600
603
-- -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) $
602
606
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."
604
609
605
610
, checkFlags [" -prof" ] $
606
611
PackageBuildWarning $
@@ -610,37 +615,43 @@ checkGhcOptions pkg =
610
615
611
616
, checkFlags [" -o" ] $
612
617
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."
614
620
615
621
, checkFlags [" -hide-package" ] $
616
622
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."
618
625
619
626
, checkFlags [" --make" ] $
620
627
PackageBuildWarning $
621
- " 'ghc-options: --make' is never needed. Cabal uses this automatically."
628
+ " 'ghc-options: --make' is never needed. Cabal uses this automatically."
622
629
623
630
, checkFlags [" -main-is" ] $
624
631
PackageDistSuspicious $
625
- " 'ghc-options: -main-is' is not portable."
632
+ " 'ghc-options: -main-is' is not portable."
626
633
627
634
, checkFlags [" -O0" , " -Onot" ] $
628
635
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."
630
638
631
639
, checkFlags [ " -O" , " -O1" ] $
632
640
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."
635
644
636
645
, checkFlags [" -O2" ] $
637
646
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."
640
650
641
651
, checkFlags [" -split-objs" ] $
642
652
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."
644
655
645
656
, checkFlags [" -optl-Wl,-s" , " -optl-s" ] $
646
657
PackageDistInexcusable $
@@ -652,7 +663,8 @@ checkGhcOptions pkg =
652
663
653
664
, checkFlags [" -fglasgow-exts" ] $
654
665
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."
656
668
657
669
, check (" -threaded" `elem` lib_ghc_options) $
658
670
PackageDistSuspicious $
@@ -695,40 +707,43 @@ checkGhcOptions pkg =
695
707
checkFlags flags = check (any (`elem` flags) all_ghc_options)
696
708
697
709
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
728
740
_ -> Nothing
729
- ghcExtension " -cpp" = Just ( EnableExtension CPP )
741
+ ghcExtension " -cpp" = enable CPP
730
742
ghcExtension _ = Nothing
731
743
744
+ enable e = Just (EnableExtension e)
745
+ disable e = Just (DisableExtension e)
746
+
732
747
checkCCOptions :: PackageDescription -> [PackageCheck ]
733
748
checkCCOptions pkg =
734
749
catMaybes [
@@ -906,15 +921,17 @@ checkCabalVersion pkg =
906
921
++ " 'other-languages' field."
907
922
908
923
-- 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)) $
910
926
PackageDistInexcusable $
911
927
" To use the 'reexported-module' field the package needs to specify "
912
928
++ " at least 'cabal-version: >= 1.21'."
913
929
914
930
-- check use of thinning and renaming
915
931
, checkVersion [1 ,21 ] (not (null depsUsingThinningRenamingSyntax)) $
916
932
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: "
918
935
++ commaSep (map display depsUsingThinningRenamingSyntax)
919
936
++ " . To use this new syntax, the package needs to specify at least"
920
937
++ " 'cabal-version: >= 1.21'."
@@ -1092,14 +1109,16 @@ checkCabalVersion pkg =
1092
1109
-- XXX: If the user writes build-depends: foo with (), this is
1093
1110
-- indistinguishable from build-depends: foo, so there won't be an
1094
1111
-- 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 [] ]
1099
1117
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 ]
1103
1122
1104
1123
usesWildcardSyntax :: VersionRange -> Bool
1105
1124
usesWildcardSyntax =
@@ -1179,8 +1198,10 @@ displayRawVersionRange =
1179
1198
(\ v -> (Disp. text " >=" <> disp v , 0 ))
1180
1199
(\ v -> (Disp. text " <=" <> disp v , 0 ))
1181
1200
(\ 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 ))
1184
1205
(\ (r, _ ) -> (Disp. parens r, 0 )) -- parens
1185
1206
1186
1207
where
0 commit comments