deiko-config 0.5.0.0 → 0.5.0.1
raw patch · 7 files changed
+192/−59 lines, 7 filesdep ~text
Dependency ranges changed: text
Files
- .gitignore +6/−0
- CHANGELOG.md +3/−0
- Data/Config.hs +78/−54
- Data/Config/Internal/DkM.hs +1/−0
- Data/Config/Internal/Typecheck.hs +1/−0
- README.md +93/−0
- deiko-config.cabal +10/−5
+ .gitignore view
@@ -0,0 +1,6 @@+*~+cabal-dev/+dist/+data/+.cabal-sandbox/+cabal.sandbox.config
+ CHANGELOG.md view
@@ -0,0 +1,3 @@+0.5.0.1+-------+* Support GHC 8.*
Data/Config.hs view
@@ -11,6 +11,81 @@ -- Stability : provisional -- Portability : non-portable --+-- Config is a small and typesafe configuration library. It provides+-- good error messages and comes with a bottom-up typechecker in order to catch+-- more configuration errors.+--+-- Here some use-cases:+--+-- >>> foo = ["bar", { baz : 42 }]+-- foo:1:8-13: Expecting String but having Object+--+-- Reason: List has only one inner type+--+-- >>> foo = ["bar"] [{ baz : 42 }]+-- foo:1:7-14: Expecting List[String] but having List[Object]+--+-- Reason: You can't merge Lists of different types+--+-- It uses <https://github.com/typesafehub/config Typesafe-config>+-- format: HOCON. HOCON stands for Human-Optimized+-- Config Object Notation. It's basically a JSON superset+--+-- Here's an example:+--+-- > -- app.conf+-- > # This is a comment+-- >+-- > foo.bar = ${toto}+-- >+-- > toto = false+-- >+-- > rawString = """+-- > This is a multi-+-- > lines String+-- > """+-- >+-- > another.string = "I'm a String"+-- >+-- > one.more.string = one more string+-- >+-- > nested {+-- > list: [ one+-- > , 1+-- > , "both"]+-- >+-- > homing = {+-- > pass: { b: feez } { a: "Prop"}+-- > }+-- >+-- > another: [1,2,3] [4,5,6]+-- > }+--+-- How to use:+--+-- @+-- -- Example.hs+-- {-# LANGUAGE OverloadedStrings #-}+-- import Data.Config+-- import Data.Text (Text)+--+-- data Foo = Foo { fooPort :: 'Int', fooAddr :: 'Text' }+--+-- main :: 'IO' ()+-- main = do+-- foo <- loadFooProps+-- withFoo foo+--+-- where+-- loadFooProps = do+-- config <- 'loadConfig' "conf/baz.conf"+-- port <- 'getInteger' "foo.port" config+-- addr <- 'getString' "foo.addr" config+-- return (Foo port addr)+--+-- withFoo :: Foo -> 'IO' ()+-- withFoo = ...+-- @ -------------------------------------------------------------------------------- module Data.Config ( Config@@ -54,59 +129,8 @@ import Data.Config.Internal.Typecheck import Data.Config.Internal.Typed -{- Here's an example:--> -- app.conf-> # This is a comment->-> foo.bar = ${toto}->-> toto = false->-> rawString = """-> This is a multi--> lines String-> """->-> another.string = "I'm a String"->-> one.more.string = one more string->-> nested {-> list: [ one-> , 1-> , "both"]->-> homing = {-> pass: { b: feez } { a: "Prop"}-> }->-> another: [1,2,3] [4,5,6]-> }--> -- Example.hs-> {-# LANGUAGE OverloadedStrings #-}->-> import Data.Config->-> data Foo = Foo { fooPort :: Int, fooAddr :: String }->-> main :: IO ()-> main = do-> foo <- loadFooProps-> withFoo foo->-> where-> loadFooProps = do-> config <- 'loadConfig' "conf/baz.conf"-> port <- 'getInteger' "foo.port" config-> addr <- 'getString' "foo.addr" config-> return (Foo port addr)->-> withFoo :: Foo -> IO ()-> withFoo = ...--} --------------------------------------------------------------------------------+-- | Configuration data newtype Config = Config { unConf :: Reg } --------------------------------------------------------------------------------@@ -136,7 +160,7 @@ Right reg -> return $ Config reg ----------------------------------------------------------------------------------- | API+-- API -------------------------------------------------------------------------------- getString :: MonadThrow m => Text -> Config -> m Text getString key conf = getValue string key conf@@ -178,7 +202,7 @@ getParsecs action key conf = getValues (parsec action) key conf ----------------------------------------------------------------------------------- | Utilities+-- Utilities -------------------------------------------------------------------------------- getValue :: MonadThrow m => Extractor a -> Text -> Config -> m a getValue extr key conf
Data/Config/Internal/DkM.hs view
@@ -19,6 +19,7 @@ import Control.Monad import Control.Monad.Reader import Control.Monad.State+import Prelude -------------------------------------------------------------------------------- newtype DkM e s a = DkM { runDkM :: e -> s -> IO (a, s) }
Data/Config/Internal/Typecheck.hs view
@@ -18,6 +18,7 @@ import Control.Exception import Data.Foldable import Data.Typeable+import Prelude -------------------------------------------------------------------------------- import Control.Monad.State.Strict
+ README.md view
@@ -0,0 +1,93 @@+Small configuration library written in Haskell++[](https://travis-ci.org/YoEight/deiko-config)++##Overview++Uses [Typesafe-config](https://github.com/typesafehub/config)'s format: HOCON++HOCON stands for Human-Optimized Config Object Notation. It's basically a JSON superset++Here's an example:++```+# This is a comment++foo.bar = ${toto}++toto = false++rawString = """+ This is a multi-+ lines String+ """++another.string = "I'm a String"++one.more.string = one more string++nested {+ list: [ one+ , 1+ , "both"]+ + homing = { + pass: { b: feez } { a: "Prop"}+ }++ another: [1,2,3] [4,5,6]+}+```++More information about the format can be found on [Typesafe-config project page](https://github.com/typesafehub/config).++The library provides good error messages and comes with a bottom-up type inferencer in order to catch more configuration errors.++Here some use-cases:++1) `foo = ["bar", { baz : 42 }]`++You'll have:++```+foo:1:8-13: Expecting String but having Object+```++reason: List has only one inner type++2) `foo = ["bar"] [{ baz : 42 }]`++You'll have:++```+foo:1:7-14: Expecting List[String] but having List[Object]+```++reason: You can't merge Lists of different types++##Example++```haskell+{-# LANGUAGE OverloadedStrings #-}+import Data.Config+import Data.Text (Text)++data Foo = Foo { fooPort :: Int, fooAddr :: Text }++main :: IO ()+main = do+ foo <- loadFooProps+ withFoo foo++ where+ loadFooProps = do+ config <- loadConfig "conf/baz.conf"+ port <- getInteger "foo.port" config+ addr <- getString "foo.addr" config+ return (Foo port addr)++withFoo :: Foo -> IO ()+withFoo = ...++```+
deiko-config.cabal view
@@ -1,22 +1,27 @@ name: deiko-config-version: 0.5.0.0+version: 0.5.0.1 synopsis: Small and typesafe configuration library. description: Small and typesafe configuration library. The library provides good error messages and comes with a bottom-up typechecker in order to catch more configuration errors. license: BSD3 license-file: LICENSE author: Yorick Laupa maintainer: yo.eight@gmail.com-homepage: http://github.com/YoEight/deiko-config+homepage: https://github.com/YoEight/deiko-config bug-reports: https://github.com/YoEight/deiko-config/issues-copyright: Copyright (C) 2014 Yorick Laupa+copyright: Copyright (C) 2017 Yorick Laupa stability: experimental category: Data build-type: Simple cabal-version: >=1.18 +extra-source-files:+ .gitignore+ README.md+ CHANGELOG.md+ source-repository head type: git- location: git://github.com/YoEight/deiko-config.git+ location: https://github.com/YoEight/deiko-config.git library default-language: Haskell2010@@ -36,7 +41,7 @@ array >= 0.5 && < 0.6, mtl >= 2.0 && < 3.0, parsec >= 3.1.2,- text >= 1.0 && < 1.2,+ text >= 1.0 && < 1.3, transformers >= 0.3 && < 0.6, containers, exceptions