Copyright | (c) Matthew Peddie 2014 |
---|---|
License | BSD3 |
Maintainer | mpeddie@gmail.com |
Stability | experimental |
Portability | GHC |
Safe Haskell | None |
Language | Haskell2010 |
Converting from Language.Libconfig.Types structures to native
libconfig Configuration
s.
- encode :: Group -> MaybeT IO Configuration
- encodeAt :: Configuration -> Group -> MaybeT IO ()
- encodeValue :: Setting -> Value -> MaybeT IO ()
- encodeTo :: Group -> String -> MaybeT IO ()
- valueType :: Value -> ConfigType
- scalarType :: Scalar -> ConfigType
Encoding libconfig native data
encode :: Group -> MaybeT IO Configuration Source
Convert a top-level Group
of Setting
s 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 Setting
s and write them to the
specified Configuration
.
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