packages feed

config-schema 0.4.1.0 → 0.5.0.0

raw patch · 4 files changed

+25/−4 lines, 4 filesdep ~freedep ~kan-extensionsPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: free, kan-extensions

API changes (from Hackage documentation)

+ Config.Schema.Spec: instance Config.Schema.Spec.Spec GHC.Int.Int16
+ Config.Schema.Spec: instance Config.Schema.Spec.Spec GHC.Int.Int32
+ Config.Schema.Spec: instance Config.Schema.Spec.Spec GHC.Int.Int64
+ Config.Schema.Spec: instance Config.Schema.Spec.Spec GHC.Int.Int8
+ Config.Schema.Spec: instance Config.Schema.Spec.Spec GHC.Types.Word
+ Config.Schema.Spec: instance Config.Schema.Spec.Spec GHC.Word.Word16
+ Config.Schema.Spec: instance Config.Schema.Spec.Spec GHC.Word.Word32
+ Config.Schema.Spec: instance Config.Schema.Spec.Spec GHC.Word.Word64
+ Config.Schema.Spec: instance Config.Schema.Spec.Spec GHC.Word.Word8
- Config.Schema.Load: loadValueFromFile :: FilePath -> ValueSpecs a -> IO a
+ Config.Schema.Load: loadValueFromFile :: ValueSpecs a -> FilePath -> IO a

Files

ChangeLog.md view
@@ -1,5 +1,11 @@ # Revision history for config-schema +## 0.5.0.0++* Add Spec instances for Int and Word types. All instances+  including the previous Int instance now validate ranges.+* Changed argument order for `loadValueFromFile`+ ## 0.4.1.0  * Add `loadValueFromFile` and `SchemaError`. This is intended
config-schema.cabal view
@@ -1,5 +1,5 @@ name:                config-schema-version:             0.4.1.0+version:             0.5.0.0 synopsis:            Schema definitions for the config-value package description:         This package makes it possible to defined schemas for use when                      loading configuration files using the config-value format.
src/Config/Schema/Load.hs view
@@ -55,10 +55,10 @@ -- -- Throws 'IOError', 'ParseError', or 'SchemaError' loadValueFromFile ::-  FilePath     {- ^ filename      -} ->   ValueSpecs a {- ^ specification -} ->+  FilePath     {- ^ filename      -} ->   IO a-loadValueFromFile path spec =+loadValueFromFile spec path =   do txt <- Text.readFile path      val <- either throwIO return (parse txt)      either (throwIO . SchemaError) return (loadValue spec val)
src/Config/Schema/Spec.hs view
@@ -64,14 +64,17 @@  import           Control.Applicative              (Const(..)) import           Control.Applicative.Free         (Ap, runAp, runAp_, liftAp)+import           Data.Bits                        (Bits, toIntegralSized) import           Data.Functor.Coyoneda            (Coyoneda(..), liftCoyoneda, lowerCoyoneda, hoistCoyoneda) import           Data.Functor.Alt                 (Alt(..))+import           Data.Int import           Data.List.NonEmpty               (NonEmpty) import qualified Data.List.NonEmpty as NonEmpty import           Data.Semigroup                   (Semigroup) import           Data.Semigroup.Foldable          (asum1, foldMap1) import           Data.Text                        (Text) import qualified Data.Text as Text+import           Data.Word  ------------------------------------------------------------------------ -- Specifications for sections@@ -264,11 +267,23 @@ instance Spec Text    where valuesSpec = liftValueSpec TextSpec instance Spec Integer where valuesSpec = liftValueSpec IntegerSpec instance Spec Rational where valuesSpec = liftValueSpec RationalSpec-instance Spec Int     where valuesSpec = fromInteger <$> valuesSpec instance Spec a => Spec [a] where valuesSpec = liftValueSpec (ListSpec valuesSpec) instance (Spec a, Spec b) => Spec (Either a b) where   valuesSpec = Left <$> valuesSpec <!> Right <$> valuesSpec +instance Spec Int    where valuesSpec = sizedBitsSpec "machine-bit signed"+instance Spec Int8   where valuesSpec = sizedBitsSpec "8-bit signed"+instance Spec Int16  where valuesSpec = sizedBitsSpec "16-bit signed"+instance Spec Int32  where valuesSpec = sizedBitsSpec "32-bit signed"+instance Spec Int64  where valuesSpec = sizedBitsSpec "64-bit signed"+instance Spec Word   where valuesSpec = sizedBitsSpec "machine-bit unsigned"+instance Spec Word8  where valuesSpec = sizedBitsSpec "8-bit unsigned"+instance Spec Word16 where valuesSpec = sizedBitsSpec "16-bit unsigned"+instance Spec Word32 where valuesSpec = sizedBitsSpec "32-bit unsigned"+instance Spec Word64 where valuesSpec = sizedBitsSpec "64-bit unsigned"++sizedBitsSpec :: (Integral a, Bits a) => Text -> ValueSpecs a+sizedBitsSpec name = customSpec name (liftValueSpec IntegerSpec) toIntegralSized  -- | Specification for matching a particular atom. atomSpec :: Text -> ValueSpecs ()