| Copyright | (c) Matthew Peddie 2014 |
|---|---|
| License | BSD3 |
| Maintainer | mpeddie@gmail.com |
| Stability | experimental |
| Portability | GHC |
| Safe Haskell | None |
| Language | Haskell2010 |
Language.Libconfig.Encode
Description
Converting from Language.Libconfig.Types structures to native
libconfig Configurations.
- 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 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.
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