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

Module documentation for

There are no documented modules for this package.


Hackage stackage LTS package stackage Nightly package Build Status

Configuration (re)loader in Haskell.





This library define a universal procedure to load configurations and parse properties, also supports reload configuration files.

We can load configurations from command line, environment, configuration files such as yaml or toml etc, and we may want to have our own strategies to load configurations from multi sources and overwrite properties by orders of these sources.

PropConfig defines a common loading strategy:

  1. loadCommandLine
  2. loadEnvironment
  3. loadConfFiles
  4. load file from folder salak.conf.dir if defined
  5. load file from current folder if enabled
  6. load file from home folder if enabled
  7. file extension matching, support yaml or toml or any other loader.

Load earlier has higher orders, orders cannot be changed.

ReaderT SourcePack m defines how to read properties:

require "abc.prop"

ReloadableSourcePackT m defines how to read reloadable properties:

requireD "abc.dynamic.prop"

For commandline and environment,

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



export TEST_CONFIG_NAME=daniel

Current Directory: salak.yaml

  name: noop
  dir: ls

Current Directory: salak.toml

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

instance FromProp Config where
  fromProp = Config
    <$> "user" ? pattern "[a-z]{5,16}"
    <*> "pwd"
    <*> "ext" .?= 1

main = runSalakWith "salak" (YAML :|: TOML) $ do
  c :: Config <- require "test.config"
  lift $ print c

GHCi play

λ> import Salak
λ> import Salak.Yaml
λ> import Salak.Toml
λ> import Data.Menshen
λ> :set -XTypeApplications
λ> instance FromProp Config where fromProp = Config <$> "user" <*> "dir" <*> "ext" .?= 1
λ> f = runSalakWith "salak" (YAML :|: TOML)
λ> f (require "") >>= print @Config
Config {name = "daniel", dir = Just "ls", ext = 2}


  • Add git pull support.
  • Add automatic reloading.
comments powered byDisqus