You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Oddly enough, a Scala wrapper for Typesafe's (pure-Java) Config library.
Usage
importcom.typesafe.config._importnet.rosien.configz._importscalaz._importScalaz._valconfig=ConfigFactory.load // or some other constructor from com.typesafe.config// Config instances may be appended using Config.withFallback() semantics. (Config has a Monoid[Config])valcombinedConfig= config |+|ConfigFactory.parseFile(...)
// Define some paths to values of a certain type.valboolPath:Configz[Boolean] ="some.path.to.a.bool".path[Boolean]
valintPath:Configz[Int] ="some.path.to.an.int".path[Int]
// Get the values at the path, which may fail with a com.typesafe.config.ConfigException.valboolProp:Settings[Boolean] = config.get(boolPath)
valintProp: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 |@|):valboolIntConfig:Configz[(Boolean, Int)] = (boolPath |@| intPath)(_ -> _)
valboolIntProp:Settings[(Boolean, Int)] = config.get(boolIntConfig)
// Configz paths can have custom validation:valvalidatedIntPath= intPath.validate((_: Int) >1000, "some.path.to.an.int must be > 1000")
About
Oddly enough, a Scala wrapper for Typesafe's (pure-Java) Config library.