hocon: Small library for typesafe's configuration specification

[ bsd3, data, library ] [ Propose Tags ]

Small library for typesafe's configuration specification

[Skip to Readme]


Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


  • No Candidates
Versions [RSS],,,,
Change log ChangeLog.md
Dependencies base (>=4.7 && <5), hspec, MissingH (<=, parsec (<=, split (<= [details]
License BSD-3-Clause
Copyright 2020 Alejandro Peralta Bazas
Author Alejandro Peralta Bazas
Maintainer aleperaltabazas@gmail.com
Category Data
Home page https://github.com/aleperaltabazas/hocon#readme
Bug tracker https://github.com/aleperaltabazas/hocon/issues
Source repo head: git clone https://github.com/aleperaltabazas/hocon
Uploaded by aleperaltabazas at 2020-12-02T18:29:13Z
Downloads 507 total (11 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2020-12-02 [all 1 reports]

Readme for hocon-

[back to package description]


Small library for Typesafe's configuration specification built with parsec.

foo = bar
bar = 123
someObject {
    wow = "this is nice!"

While there are many configuration notations and formats around, HOCON stands in a comfortable place, albeit a bit underrated. Being a superset to JSON means it inherits its great readability, as well as extending it with some very nice features, such as comments, no need to add " for properties and values (unless some special character is required), digging up nested values, among others.

Sounds nice, how do I use it?

First of all, import the basic stuff:

import Data.HOCON
import Text.Parser.HOCON

The first module exports the tree-like structure typical of JSON (if you're familiar with aeson, then it's really the same structure. It's not using that structure because no way I'm including that just for the structure) and the accessor functions, while the second exports the parser function:

parseHOCON :: String -> Either ParseError Config

If you've already used Typesafe's config on the JVM, then the functions will make you feel just like at home:

getConfig :: String -> Config -> Maybe Config
getNumber :: String -> Config -> Maybe Double
getString :: String -> Config -> Maybe String
getBoolean :: String -> Config -> Maybe Bool
getList :: String -> Config -> Maybe [Config]
hasPath :: String -> Config -> Bool

Missing features / what's to come

  • Actually support comments
  • Multiline strings
  • Include another file and merge them
  • Object substitution

Pull requests are always welcome!