The conf package

[Tags:bsd3, library, test]

This package is designed to allow you to create configuration files with declarative Haskell and parse the values back into Haskell code. The benefit here is to have a configuration file in Haskell that does not have to be recompiled - it is interpreted/parsed at runtime in a type-safe manner.

Example usage:

 -- /path/to/my-config.hs
 foo = ["bar", "baz"]
 spam = Eggs
 -- Application source
 import Data.Conf
 import Data.Maybe

 data Spam = Eggs | Parrot | SomethingEntirelyDifferent
     deriving (Show, Read)

 getSpam :: Conf -> Spam
 getSpam = fromMaybe SomethingEntirelyDifferent . getConf "spam"

 getFoo :: Conf -> Maybe Int
 getFoo = getConf "foo"

 main = do
     conf <- readConf "my-config.hs"
     print $ getSpam conf -- Output: Eggs
     print $ getFoo conf  -- Output: Nothing

[Skip to Readme]

Properties

Versions 0.1.0.0, 0.1.1.0
Dependencies base (>=4.6 && <4.8), haskell-src [details]
License BSD3
Copyright Copyright (C) 2015 Cary M. Robbins
Author Cary M. Robbins
Maintainer carymrobbins@gmail.com
Category Configuration, Parsing
Source repository head: git clone git://github.com/carymrobbins/haskell-conf.git
Uploaded Fri Jul 17 14:00:09 UTC 2015 by carymrobbins
Distributions NixOS:0.1.1.0
Downloads 493 total (11 in the last 30 days)
Votes
0 []
Status Docs available [build log]
Last success reported on 2015-07-17 [all 1 reports]
Hackage Matrix CI

Modules

[Index]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees

Readme for conf

Readme for conf-0.1.1.0

Conf: Parser for Haskell-based configuration files.

Installation

You can install this library from Hackage via cabal install conf

Description

This package is designed to allow you to create configuration files with declarative Haskell and parse the values back into Haskell code. The benefit here is to have a configuration file in Haskell that does not have to be recompiled - it is interpreted/parsed at runtime in a type-safe manner.

Example usage:

-- /path/to/my-config.hs
foo = ["bar", "baz"]
spam = Eggs
-- Application source
import Data.Conf
import Data.Maybe

data Spam = Eggs | Parrot | SomethingEntirelyDifferent
    deriving (Show, Read)

getSpam :: Conf -> Spam
getSpam = fromMaybe SomethingEntirelyDifferent . getConf "spam"

getFoo :: Conf -> Maybe Int
getFoo = getConf "foo"

main = do
    conf <- readConf "my-config.hs"
    print $ getSpam conf -- Output: Eggs
    print $ getFoo conf  -- Output: Nothing

Building

cabal sandbox init  # If you haven't already
cabal install -j --dependencies-only
cabal build

Running the Tests

cabal sandbox init  # If you haven't already
cabal install -j --enable-tests --dependencies-only
cabal test