packages feed

hpack 0.6.0 → 0.7.0

raw patch · 6 files changed

+69/−25 lines, 6 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Hpack.Config: instance Selector S1_0_5CommonOptions
+ Hpack.Config: section :: a -> Section a
+ Hpack.Config: sectionGhcProfOptions :: Section a -> [GhcProfOption]
- Hpack.Config: Section :: a -> [FilePath] -> [Dependency] -> [String] -> [GhcOption] -> [CppOption] -> Section a
+ Hpack.Config: Section :: a -> [FilePath] -> [Dependency] -> [String] -> [GhcOption] -> [GhcProfOption] -> [CppOption] -> Section a

Files

hpack.cabal view
@@ -3,7 +3,7 @@ -- see: https://github.com/sol/hpack  name:           hpack-version:        0.6.0+version:        0.7.0 synopsis:       An alternative format for Haskell packages category:       Development homepage:       https://github.com/sol/hpack#readme
src/Hpack/Config.hs view
@@ -12,6 +12,7 @@   packageConfig , readPackageConfig , package+, section , Package(..) , Dependency(..) , GitRef(..)@@ -51,6 +52,9 @@ package :: String -> String -> Package package name version = Package name version Nothing Nothing Nothing Nothing Nothing Nothing [] [] [] Nothing Nothing Nothing [] [] Nothing Nothing [] [] +section :: a -> Section a+section a = Section a [] [] [] [] [] []+ packageConfig :: FilePath packageConfig = "package.yaml" @@ -113,6 +117,7 @@ , commonOptionsDependencies :: Maybe (List Dependency) , commonOptionsDefaultExtensions :: Maybe (List String) , commonOptionsGhcOptions :: Maybe (List GhcOption)+, commonOptionsGhcProfOptions :: Maybe (List GhcProfOption) , commonOptionsCppOptions :: Maybe (List CppOption) } deriving (Eq, Show, Generic) @@ -212,8 +217,6 @@ , gitRefRef :: String } deriving (Eq, Show, Ord, Generic) -type CppOption = String- data Package = Package {   packageName :: String , packageVersion :: String@@ -254,6 +257,7 @@ , sectionDependencies :: [Dependency] , sectionDefaultExtensions :: [String] , sectionGhcOptions :: [GhcOption]+, sectionGhcProfOptions :: [GhcProfOption] , sectionCppOptions :: [CppOption] } deriving (Eq, Show, Functor, Foldable, Traversable) @@ -345,7 +349,7 @@     formatUnknownSectionFields sectionType = concatMap f . map (fmap captureUnknownFieldsFields)       where         f :: (String, [String]) -> [String]-        f (section, fields) = formatUnknownFields (sectionType ++ " section " ++ show section) fields+        f (sect, fields) = formatUnknownFields (sectionType ++ " section " ++ show sect) fields      formatMissingSourceDirs = map f       where@@ -375,13 +379,13 @@         fromGithub = (++ "/issues") . sourceRepositoryUrl <$> sourceRepository  toLibrary :: Section global -> Section LibrarySection -> IO (Section Library)-toLibrary globalOptions library = traverse fromLibrarySection section+toLibrary globalOptions library = traverse fromLibrarySection sect   where-    section :: Section LibrarySection-    section = mergeSections globalOptions library+    sect :: Section LibrarySection+    sect = mergeSections globalOptions library      sourceDirs :: [FilePath]-    sourceDirs = sectionSourceDirs section+    sourceDirs = sectionSourceDirs sect      fromLibrarySection :: LibrarySection -> IO Library     fromLibrarySection LibrarySection{..} = do@@ -396,9 +400,9 @@     sections = map (fmap $ mergeSections globalOptions) executables      toExecutable :: (String, Section ExecutableSection) -> IO (Section Executable)-    toExecutable (name, section@Section{..}) = do+    toExecutable (name, sect@Section{..}) = do       (executable, ghcOptions) <- fromExecutableSection sectionData-      return (section {sectionData = executable, sectionGhcOptions = sectionGhcOptions ++ ghcOptions})+      return (sect {sectionData = executable, sectionGhcOptions = sectionGhcOptions ++ ghcOptions})       where         fromExecutableSection :: ExecutableSection -> IO (Executable, [GhcOption])         fromExecutableSection ExecutableSection{..} = do@@ -412,22 +416,24 @@  mergeSections :: Section global -> Section a -> Section a mergeSections globalOptions options-  = Section a sourceDirs dependencies defaultExtensions ghcOptions cppOptions+  = Section a sourceDirs dependencies defaultExtensions ghcOptions ghcProfOptions cppOptions   where     a = sectionData options     sourceDirs = sectionSourceDirs globalOptions ++ sectionSourceDirs options     defaultExtensions = sectionDefaultExtensions globalOptions ++ sectionDefaultExtensions options     ghcOptions = sectionGhcOptions globalOptions ++ sectionGhcOptions options+    ghcProfOptions = sectionGhcProfOptions globalOptions ++ sectionGhcProfOptions options     cppOptions = sectionCppOptions globalOptions ++ sectionCppOptions options     dependencies = sectionDependencies globalOptions ++ sectionDependencies options  toSection :: a -> CommonOptions -> Section a toSection a CommonOptions{..}-  = Section a sourceDirs dependencies defaultExtensions ghcOptions cppOptions+  = Section a sourceDirs dependencies defaultExtensions ghcOptions ghcProfOptions cppOptions   where     sourceDirs = fromMaybeList commonOptionsSourceDirs     defaultExtensions = fromMaybeList commonOptionsDefaultExtensions     ghcOptions = fromMaybeList commonOptionsGhcOptions+    ghcProfOptions = fromMaybeList commonOptionsGhcProfOptions     cppOptions = fromMaybeList commonOptionsCppOptions     dependencies = fromMaybeList commonOptionsDependencies 
src/Hpack/Run.hs view
@@ -141,27 +141,27 @@ renderExecutables = map renderExecutable  renderExecutable :: Section Executable -> Element-renderExecutable section@(sectionData -> Executable{..}) =-  Stanza ("executable " ++ executableName) (renderExecutableSection section)+renderExecutable sect@(sectionData -> Executable{..}) =+  Stanza ("executable " ++ executableName) (renderExecutableSection sect)  renderTests :: [Section Executable] -> [Element] renderTests = map renderTest  renderTest :: Section Executable -> Element-renderTest section@(sectionData -> Executable{..}) =+renderTest sect@(sectionData -> Executable{..}) =   Stanza ("test-suite " ++ executableName)-    (Field "type" "exitcode-stdio-1.0" : renderExecutableSection section)+    (Field "type" "exitcode-stdio-1.0" : renderExecutableSection sect)  renderExecutableSection :: Section Executable -> [Element]-renderExecutableSection section@(sectionData -> Executable{..}) =-  mainIs : renderSection section ++ [otherModules, defaultLanguage]+renderExecutableSection sect@(sectionData -> Executable{..}) =+  mainIs : renderSection sect ++ [otherModules, defaultLanguage]   where     mainIs = Field "main-is" (Literal executableMain)     otherModules = renderOtherModules executableOtherModules  renderLibrary :: Section Library -> Element-renderLibrary section@(sectionData -> Library{..}) = Stanza "library" $-  renderSection section ++ [+renderLibrary sect@(sectionData -> Library{..}) = Stanza "library" $+  renderSection sect ++ [     renderExposedModules libraryExposedModules   , renderOtherModules libraryOtherModules   , defaultLanguage@@ -172,6 +172,7 @@     renderSourceDirs sectionSourceDirs   , renderDefaultExtensions sectionDefaultExtensions   , renderGhcOptions sectionGhcOptions+  , renderGhcProfOptions sectionGhcProfOptions   , renderCppOptions sectionCppOptions   , renderDependencies sectionDependencies   ]@@ -194,7 +195,10 @@ renderGhcOptions :: [GhcOption] -> Element renderGhcOptions = Field "ghc-options" . WordList -renderCppOptions :: [GhcOption] -> Element+renderGhcProfOptions :: [GhcProfOption] -> Element+renderGhcProfOptions = Field "ghc-prof-options" . WordList++renderCppOptions :: [CppOption] -> Element renderCppOptions = Field "cpp-options" . WordList  renderDefaultExtensions :: [String] -> Element
src/Hpack/Util.hs view
@@ -3,6 +3,8 @@ module Hpack.Util (   List(..) , GhcOption+, GhcProfOption+, CppOption , parseMain , toModule , getFilesRecursive@@ -48,6 +50,8 @@     _ -> return <$> parseJSON v  type GhcOption = String+type GhcProfOption = String+type CppOption = String  parseMain :: String -> (FilePath, [GhcOption]) parseMain main = case reverse name of
test/Hpack/ConfigSpec.hs view
@@ -7,7 +7,6 @@ , package , executable , library-, section ) where  import           Helper@@ -28,9 +27,6 @@ library :: Library library = Library [] [] -section :: a -> Section a-section a = Section a [] [] [] [] []- spec :: Spec spec = do   describe "parseJSON" $ do@@ -520,6 +516,27 @@           |]         Right (_, c) <- readPackageConfig "package.yaml"         c `shouldBe` package {packageExecutables = [(section $ executable "foo" "driver/Main.hs") {sectionGhcOptions = ["-Wall"]}]}++      it "accepts GHC profiling options" $ do+        writeFile "package.yaml" [i|+          executables:+            foo:+              main: driver/Main.hs+              ghc-prof-options: -fprof-auto+          |]+        Right (_, c) <- readPackageConfig "package.yaml"+        c `shouldBe` package {packageExecutables = [(section $ executable "foo" "driver/Main.hs") {sectionGhcProfOptions = ["-fprof-auto"]}]}++      it "accepts global GHC profiling options" $ do+        writeFile "package.yaml" [i|+          ghc-prof-options: -fprof-auto+          executables:+            foo:+              main: driver/Main.hs+          |]+        Right (_, c) <- readPackageConfig "package.yaml"+        c `shouldBe` package {packageExecutables = [(section $ executable "foo" "driver/Main.hs") {sectionGhcProfOptions = ["-fprof-auto"]}]}+      context "when reading test section" $ do       it "warns on unknown fields" $ do
test/Hpack/RunSpec.hs view
@@ -150,6 +150,19 @@           , "  default-language: Haskell2010"           ] +      it "includes GHC profiling options" $ do+        renderPackage_ 0 [] package {packageExecutables = [(section $ executable "foo" "Main.hs") {sectionGhcProfOptions = ["-fprof-auto", "-rtsopts"]}]} `shouldBe` unlines [+            "name: foo"+          , "version: 0.0.0"+          , "build-type: Simple"+          , "cabal-version: >= 1.10"+          , ""+          , "executable foo"+          , "  main-is: Main.hs"+          , "  ghc-prof-options: -fprof-auto -rtsopts"+          , "  default-language: Haskell2010"+          ]+   describe "formatDescription" $ do     it "formats description" $ do       let description = unlines [