BSD-3-Clause licensed by Daniel YU
Maintained by Daniel YU

Module documentation for 0.1.11

This version can be pinned in stack with:salak-0.1.11@sha256:ce4360fd52fea569f27e1fbcf842ca18122f19026cfc2aca69af12ca5e02841a,1830


Hackage stackage LTS package stackage Nightly package Build Status

Configuration Loader in Haskell.

This library default a standard configuration load process. It can load properties from CommandLine, Environment, JSON value and Yaml files. They all load to the same format SourcePack. Earler property source has higher order to load property. For example:

CommandLine:  --package.a.enabled=true
Environment: PACKAGE_A_ENABLED: false

lookup "package.a.enabled" properties => Just True

CommandLine has higher order then Environment, for the former load properties earler then later.


data Config = Config
  { name :: Text
  , dir  :: Maybe Text
  , ext  :: Int
  } deriving (Eq, Show)

instance FromProp Config where
  fromProp = Config
    <$> "user"
    <*> "pwd"
    <*> "ext" .?= 1

main = do
  c :: Config <- defaultLoadSalak def $ require ""
  print c
λ> c
Config {name = "daniel", dir = Nothing, ext = 1}