libconfig-0.2.0.0: Haskell bindings to libconfig

Copyright(c) Matthew Peddie 2014
LicenseBSD3
Maintainermpeddie@gmail.com
Stabilityexperimental
PortabilityGHC
Safe HaskellNone
LanguageHaskell2010

Language.Libconfig.Encode

Contents

Description

Converting from Language.Libconfig.Types structures to native libconfig Configurations.

Synopsis

Encoding libconfig native data

encode :: Group -> MaybeT IO Configuration Source

Convert a top-level Group of Settings into a native Configuration. This allocates a new Configuration.

>>> Just conf <- runMaybeT $ encode test
>>> C.configWriteFile conf "/tmp/encode_output_test.conf"
Just ()
>>> Just newconf <- C.configNew "/tmp/encode_output_test.conf"

encodeAt :: Configuration -> Group -> MaybeT IO () Source

Encode a top-level Group of Settings and write them to the specified Configuration.

encodeValue :: Setting -> Value -> MaybeT IO () Source

Set the value of the given Setting to the provided Value (recursively). If this Setting is of a collection type, any pre-existing children will be removed.

encodeTo :: Group -> String -> MaybeT IO () Source

Convert a top-level Group of Settings into a native libconfig structure and output it to the specified file path.

>>> runMaybeT $ encodeTo test "/tmp/encode_output_test_2.conf"
Just ()
>>> Just newconf <- C.configNew "/tmp/encode_output_test.conf"

Helpers

valueType :: Value -> ConfigType Source

Compute the ConfigType of a Value

>>> valueType (Scalar (String "butts"))
StringType
>>> valueType (Array [String "butts"])
ArrayType

scalarType :: Scalar -> ConfigType Source

Compute the ConfigType of a Scalar

>>> scalarType (String "butts")
StringType
>>> scalarType (Boolean False)
BoolType