confide: derive typeclass instances for decoding types from HOCON conf

[ bsd3, data, library ] [ Propose Tags ] [ Report a vulnerability ]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.0.1, 0.1.0.2, 0.1.0.3
Dependencies base (>=4.7 && <5), deiko-config (>=0.5.0.1), exceptions (==0.8.3), text (==1.2.2.2) [details]
License BSD-3-Clause
Copyright 2018 Alex Milkov
Author Alex Milkov
Maintainer amilkov3@gmail.com
Category Data
Home page https://github.com/amilkov3/confide
Bug tracker https://github.com/amilkov3/confide/issues
Source repo head: git clone https://github.com/amilkov3/confide
Uploaded by amilkov at 2018-03-08T19:18:27Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 2356 total (16 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2018-03-08 [all 1 reports]

Readme for confide-0.1.0.3

[back to package description]

confide

Build status

Confide port to Haskell (using GHC.Generics as opposed to Shapeless to generate FromConf typeclass instances). Uses deiko-config to parse HOCON .conf file and read in types

Usage

HOCON .conf file

a="hello"

b {
  y=true
  z {
    x=5
  }
}

{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeApplications #-}

module Test where

import Data.Confide
import Data.Confide.Generic
import qualified Data.Text as T

data Foo = Foo {x :: Integer} deriving (Generic, Show)
data Bar = Bar {y :: Bool, z :: Foo} deriving (Generic, Show)
data Baz = Baz {a :: T.Text, b :: Bar} deriving (Generic, Show)

instance FromConf Foo
instance FromConf Bar
instance FromConf Baz

main :: IO ()
main = do
  c <- loadConfig "project/path/to/confFile.conf"
  baz <- get @Baz "" c
  print baz

GHCI

$ main 
Baz {a = "hello", b = Bar {y = True, z = Foo {x = 5}}}