deiko-config: Small and typesafe configuration library.

[ bsd3, data, library ] [ Propose Tags ] [ Report a vulnerability ]

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.


[Skip to Readme]

Modules

[Index]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.5.0.0, 0.5.0.1
Change log CHANGELOG.md
Dependencies array (>=0.5 && <0.6), base (>=4.7 && <5), containers, exceptions, mtl (>=2.0 && <3.0), parsec (>=3.1.2), text (>=1.0 && <1.3), transformers (>=0.3 && <0.6) [details]
License BSD-3-Clause
Copyright Copyright (C) 2017 Yorick Laupa
Author Yorick Laupa
Maintainer yo.eight@gmail.com
Category Data
Home page https://github.com/YoEight/deiko-config
Bug tracker https://github.com/YoEight/deiko-config/issues
Source repo head: git clone https://github.com/YoEight/deiko-config.git
Uploaded by YorickLaupa at 2017-11-09T08:56:19Z
Distributions
Reverse Dependencies 2 direct, 0 indirect [details]
Downloads 2087 total (10 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2017-11-09 [all 1 reports]

Readme for deiko-config-0.5.0.1

[back to package description]

Small configuration library written in Haskell

Build Status

##Overview

Uses Typesafe-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.

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

  1. 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

{-# 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 = ...