salak: Configuration Loader

[ configuration, library, mit ] [ Propose Tags ]
This version is deprecated.

Configuration Loader for Production in Haskell


[Skip to Readme]

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0, 0.1.1, 0.1.2, 0.1.3, 0.1.4, 0.1.5, 0.1.6, 0.1.7, 0.1.8, 0.1.9, 0.1.10, 0.1.11, 0.2.0, 0.2.1, 0.2.2, 0.2.3, 0.2.4, 0.2.5, 0.2.6, 0.2.7, 0.2.8, 0.2.9, 0.2.9.1, 0.2.9.2, 0.2.9.3, 0.2.10, 0.3, 0.3.1, 0.3.2, 0.3.3, 0.3.3.1, 0.3.3.2, 0.3.4, 0.3.4.1, 0.3.5, 0.3.5.1, 0.3.5.2, 0.3.5.3, 0.3.6 (info)
Dependencies aeson (<1.5), attoparsec (<0.14), base (>=4.8 && <5), containers (<0.7), data-default (<0.8), directory (<1.4), filepath (<1.5), menshen (<0.1), mtl (<2.3), pqueue (<1.5), scientific (<0.4), stm (<2.6), text (<1.3), transformers (<0.6), unordered-containers (<0.3), vector (<0.13), yaml (<0.12) [details]
License BSD-3-Clause
Copyright (c) 2018 Daniel YU
Author Daniel YU
Maintainer Daniel YU <leptonyu@gmail.com>
Revised Revision 1 made by leptonyu at 2019-09-05T03:25:39Z
Category Library
Home page https://github.com/leptonyu/salak#readme
Uploaded by leptonyu at 2019-03-28T08:09:34Z
Distributions
Reverse Dependencies 10 direct, 0 indirect [details]
Downloads 14466 total (94 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for salak-0.2.4

[back to package description]

salak

Hackage stackage LTS package stackage Nightly package Build Status

Configuration Loader for Production 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.

Usage:

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}