packages feed

hie-bios 0.7.6 → 0.8.0

raw patch · 7 files changed

+54/−25 lines, 7 filesdep ~aesonPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: aeson

API changes (from Hackage documentation)

- HIE.Bios.Cradle: loadCustomCradle :: FromJSON b => (b -> Cradle a) -> FilePath -> IO (Cradle a)
- HIE.Bios.Types: CradleOpts :: BIOSVerbosity -> Maybe Handle -> CradleOpts
- HIE.Bios.Types: [cradleOptsHandle] :: CradleOpts -> Maybe Handle
- HIE.Bios.Types: [cradleOptsVerbosity] :: CradleOpts -> BIOSVerbosity
- HIE.Bios.Types: data CradleOpts
- HIE.Bios.Types: defaultCradleOpts :: CradleOpts

Files

ChangeLog.md view
@@ -1,5 +1,10 @@ # ChangeLog hie-bios +## 2021-11-29 - 0.8.0++* Support aeson >= 2.0. [#313](https://github.com/haskell/hie-bios/pull/313)+* Remove CradleOpt Type [#293](https://github.com/haskell/hie-bios/pull/293)+ ## 2021-08-30 - 0.7.6  * Don't look for NIX_GHC_LIBDIR as it is redundant [#294](https://github.com/mpickering/hie-bios/pull/294)
exe/Main.hs view
@@ -59,13 +59,13 @@ main = do     hSetEncoding stdout utf8     cwd <- getCurrentDirectory+    cmd <- execParser progInfo     cradle <-         -- find cradle does a takeDirectory on the argument, so make it into a file         findCradle (cwd </> "File.hs") >>= \case           Just yaml -> loadCradle yaml           Nothing -> loadImplicitCradle (cwd </> "File.hs") -    cmd <- execParser progInfo      res <- case cmd of       Check targetFiles -> checkSyntax cradle targetFiles
hie-bios.cabal view
@@ -1,6 +1,6 @@ Cabal-Version:          2.2 Name:                   hie-bios-Version:                0.7.6+Version:                0.8.0 Author:                 Matthew Pickering <matthewtpickering@gmail.com> Maintainer:             Matthew Pickering <matthewtpickering@gmail.com> License:                BSD-3-Clause@@ -146,7 +146,7 @@   autogen-modules:      Paths_hie_bios   Build-Depends:                         base                 >= 4.8 && < 5,-                        aeson                >= 1.4.5 && < 2,+                        aeson                >= 1.4.5 && < 2.1,                         base16-bytestring    >= 0.1.1 && < 1.1,                         bytestring           >= 0.10.8 && < 0.12,                         deepseq              >= 1.4.3 && < 1.5,@@ -191,6 +191,7 @@   default-language: Haskell2010   build-depends:       base,+      aeson,       filepath,       hie-bios,       hspec-expectations,
src/HIE/Bios/Config.hs view
@@ -5,6 +5,7 @@ {-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE ViewPatterns #-} {-# LANGUAGE LambdaCase #-}+{-# LANGUAGE CPP #-} -- | Logic and datatypes for parsing @hie.yaml@ files. module HIE.Bios.Config(     readConfig,@@ -24,7 +25,13 @@ import Control.Exception import qualified Data.Text as T import qualified Data.Vector as V+#if MIN_VERSION_aeson(2,0,0)+import           Data.Aeson.Key (fromText)+import           Data.Aeson.KeyMap (KeyMap)+import qualified Data.Aeson.KeyMap as Map+#else import qualified Data.HashMap.Strict as Map+#endif import           Data.Maybe (mapMaybe) import           Data.Monoid (Last(..)) import           Data.Foldable (foldrM)@@ -32,6 +39,22 @@ import           Data.Yaml import           Data.Yaml.Internal (Warning(..)) ++#if !MIN_VERSION_aeson(2,0,0)+-- | Backwards compatible type-def for Key+-- This used to be just a Text, but since aeson >= 2+-- this is an opaque datatype.+type Key = T.Text+-- | Backwards compatible type-def for KeyMap+-- This used to be just a HashMap, but since aeson >= 2+-- this is an opaque datatype.+type KeyMap v = Map.HashMap T.Text v++-- | Create a Key from a Text.+fromText :: T.Text -> Key+fromText = id+#endif+ -- | Configuration that can be used to load a 'Cradle'. -- A configuration has roughly the following form: --@@ -149,7 +172,7 @@   :: Monoid x   => (x -> CradleType a)   -> (x -> [(FilePath, x)] -> CradleType a)-  -> (Map.HashMap T.Text Value -> Parser x)+  -> (KeyMap Value -> Parser x)   -> Value   -> Parser (CradleType a) parseSingleOrMultiple single multiple parse = doParse where@@ -224,7 +247,7 @@         exclusive l Nothing = l         exclusive Nothing r = r         stringTypeFromMap :: (String -> t) -> T.Text -> Maybe t-        stringTypeFromMap constructor name = constructor <$> (intoString =<< Map.lookup name x)+        stringTypeFromMap constructor name = constructor <$> (intoString =<< Map.lookup (fromText name) x)         intoString :: Value -> Maybe String         intoString (String s) = Just (T.unpack s)         intoString _ = Nothing
src/HIE/Bios/Cradle.hs view
@@ -5,7 +5,6 @@ module HIE.Bios.Cradle (       findCradle     , loadCradle-    , loadCustomCradle     , loadImplicitCradle     , yamlConfig     , defaultCradle@@ -75,10 +74,7 @@  -- | Given root\/hie.yaml load the Cradle. loadCradle :: FilePath -> IO (Cradle Void)-loadCradle = loadCradleWithOpts Types.defaultCradleOpts absurd--loadCustomCradle :: Yaml.FromJSON b => (b -> Cradle a) -> FilePath -> IO (Cradle a)-loadCustomCradle = loadCradleWithOpts Types.defaultCradleOpts+loadCradle = loadCradleWithOpts absurd  -- | Given root\/foo\/bar.hs, load an implicit cradle loadImplicitCradle :: Show a => FilePath -> IO (Cradle a)@@ -93,8 +89,8 @@ --   Find a cabal file by tracing ancestor directories. --   Find a sandbox according to a cabal sandbox config --   in a cabal directory.-loadCradleWithOpts :: (Yaml.FromJSON b) => CradleOpts -> (b -> Cradle a) -> FilePath -> IO (Cradle a)-loadCradleWithOpts _copts buildCustomCradle wfile = do+loadCradleWithOpts :: (Yaml.FromJSON b) => (b -> Cradle a) -> FilePath -> IO (Cradle a)+loadCradleWithOpts buildCustomCradle wfile = do     cradleConfig <- readCradleConfig wfile     return $ getCradle buildCustomCradle (cradleConfig, takeDirectory wfile) 
src/HIE/Bios/Types.hs view
@@ -8,19 +8,9 @@ module HIE.Bios.Types where  import           System.Exit-import           System.IO import           Control.Exception              ( Exception )  data BIOSVerbosity = Silent | Verbose--data CradleOpts = CradleOpts-                { cradleOptsVerbosity :: BIOSVerbosity-                , cradleOptsHandle :: Maybe Handle-                -- ^ The handle where to send output to, if not set, stderr.-                }--defaultCradleOpts :: CradleOpts-defaultCradleOpts = CradleOpts Silent Nothing  ---------------------------------------------------------------- 
tests/ParserTests.hs view
@@ -1,19 +1,25 @@ {-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE CPP #-} module Main where  import Test.Hspec.Expectations import Test.Tasty import Test.Tasty.HUnit import HIE.Bios.Config+#if MIN_VERSION_aeson(2,0,0)+import           Data.Aeson.Key ( Key )+import qualified Data.Aeson.KeyMap as Map+#else import qualified Data.HashMap.Strict as Map+import qualified Data.Text as T+#endif import Data.Void import Data.Yaml-import qualified Data.Text as T import System.FilePath import Control.Applicative ( (<|>) ) import Control.Exception -configDir :: FilePah+configDir :: FilePath configDir = "tests/configs"  main :: IO ()@@ -120,7 +126,7 @@    parseJSON _ = fail "Not a valid cabal-helper specification" -simpleCabalHelperYaml :: T.Text -> Value+simpleCabalHelperYaml :: Key -> Value simpleCabalHelperYaml tool =   object     [ ( "cabal-helper", object@@ -128,3 +134,11 @@         ]       )     ]++-- ------------------------------------------------------------------+-- Helper functions to support aeson < 2+-- ------------------------------------------------------------------++#if !MIN_VERSION_aeson(2,0,0)+type Key = T.Text+#endif