https://github.com/yoeight/deiko-config
A small configuration library written in Haskell
https://github.com/yoeight/deiko-config
Last synced: about 1 year ago
JSON representation
A small configuration library written in Haskell
- Host: GitHub
- URL: https://github.com/yoeight/deiko-config
- Owner: YoEight
- License: bsd-3-clause
- Created: 2013-05-30T22:51:02.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2019-10-12T15:41:15.000Z (over 6 years ago)
- Last Synced: 2025-04-26T07:36:26.002Z (about 1 year ago)
- Language: Haskell
- Homepage:
- Size: 121 KB
- Stars: 17
- Watchers: 4
- Forks: 3
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
Small configuration library written in Haskell
[](https://travis-ci.org/YoEight/deiko-config)
##Overview
Uses [Typesafe-config](https://github.com/typesafehub/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](https://github.com/typesafehub/config).
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
2) `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
```haskell
{-# 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 = ...
```