conf: Parser for Haskell-based configuration files.

[ bsd3, configuration, library, parsing ] [ Propose Tags ]

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 Foo
getFoo = getConf "foo"

main = do
    conf <- readConf "my-config.hs"
    let spam = getSpam conf
    print spam
    let foo = getFoo conf
    print foo

[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.1.0
Dependencies base (>=4.6 && <4.7), haskell-src [details]
License BSD-3-Clause
Copyright Copyright (C) 2014 Cary M. Robbins
Author Cary M. Robbins
Maintainer carymrobbins@gmail.com
Category Configuration, Parsing
Source repo head: git clone git://github.com/carymrobbins/haskell-conf.git
Uploaded by carymrobbins at 2014-02-07T04:16:07Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 1874 total (7 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Successful builds reported [all 1 reports]

Readme for conf-0.1.0.0

[back to package description]

Conf: Haskell-Style Config Parsing

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 configuration "my-config"
foo = ["bar", "baz"]
spam = Eggs
-- Example application
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 "/path/to/my-config"
    let spam = getSpam conf
    print spam  -- Output: "Eggs"
    let foo = getFoo conf
    print foo   -- Output: "Nothing"