Giter Club home page Giter Club logo

haskell-conf's Introduction

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

haskell-conf's People

Contributors

carymrobbins avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.