Giter VIP home page Giter VIP logo

deiko-config's Introduction

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

deiko-config's People

Contributors

yoeight avatar

Watchers

James Cloos avatar  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.