Skip to content
Oddly enough, a Scala wrapper for Typesafe's (pure-Java) Config library.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
core/src
project
LICENSE-2.0.txt
README.md
version.sbt

README.md

Oddly enough, a Scala wrapper for Typesafe's (pure-Java) Config library.

Usage

import com.typesafe.config._
import net.rosien.configz._
import scalaz._
import Scalaz._

val config = ConfigFactory.load // or some other constructor from com.typesafe.config

// Config instances may be appended using Config.withFallback() semantics. (Config has a Monoid[Config])
val combinedConfig = config |+| ConfigFactory.parseFile(...)

// Define some paths to values of a certain type.
val boolPath: Configz[Boolean] = "some.path.to.a.bool".path[Boolean]
val intPath:  Configz[Int]     = "some.path.to.an.int".path[Int]

// Get the values at the path, which may fail with a com.typesafe.config.ConfigException.
val boolProp: Settings[Boolean] = config.get(boolPath)
val intProp:  Settings[Int]     = config.get(intPath)

// Note that Settings[A] is an alias for ValidationNEL[ConfigException, A].

// Configz is an applicative functor, so you can combine them (using scalaz operators like <*> or |@|):
val boolIntConfig: Configz[(Boolean, Int)]  = (boolPath |@| intPath)(_ -> _)
val boolIntProp:   Settings[(Boolean, Int)] = config.get(boolIntConfig)

// Configz paths can have custom validation:
val validatedIntPath = intPath.validate((_: Int) > 1000, "some.path.to.an.int must be > 1000")
You can’t perform that action at this time.