salak: Configuration Loader

[ configuration, library, mit, program ] [ Propose Tags ]

[Skip to Readme]
Versions [faq] 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 (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), 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 Thu Sep 5 03:24:47 UTC 2019
Category Library
Home page https://github.com/leptonyu/salak#readme
Uploaded by leptonyu at Fri Mar 29 03:13:16 UTC 2019
Distributions LTSHaskell:0.3.5.2, NixOS:0.3.5.3, Stackage:0.3.5.2
Downloads 4465 total (213 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs uploaded by user
Build status unknown [no reports yet]

Modules

[Index] [Quick Jump]

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

For package maintainers and hackage trustees


Readme for salak-0.2.6

[back to package description]

salak

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.

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}