Safe Haskell | None |
---|---|
Language | Haskell2010 |
B9 produces not only VM-Images but also text documents such as configuration files required by virtual machines. This module is about creating and merging files containing parsable syntactic structures, such as most configuration files do.
B9 can be used to create configuration files by assembling structured documents, for example Yaml, JSON, Erlang Terms.
One example is creating a single cloud-init 'user-data' file from a set of
'user-data' snippets - all of which using yaml syntax to declare the same
object (e.g "user-data"
).
The goal is, that b9 is able to merge these snippets into one, intelligently
merging fields as one would expect, e.g. when merging multiple snippets with
writefiles
fields, the output object's writefiles
field contains all the
write_file
objects.
Another example is the OTPErlang sys.config for configuring OTPErlang releases.
Synopsis
- class FromAST a where
- fromAST :: (IsB9 e, ToContentGenerator c) => AST c a -> Eff e a
- data AST c a
- parseFromTextWithErrorMessage :: (HasCallStack, Textual a) => String -> Text -> Either String a
Documentation
class FromAST a where Source #
Types of values that describe content, that can be created from an AST
.
Instances
FromAST YamlObject Source # | |
Defined in B9.Artifact.Content.YamlObject fromAST :: (IsB9 e, ToContentGenerator c) => AST c YamlObject -> Eff e YamlObject Source # | |
FromAST ErlangPropList Source # | |
Defined in B9.Artifact.Content.ErlangPropList fromAST :: (IsB9 e, ToContentGenerator c) => AST c ErlangPropList -> Eff e ErlangPropList Source # | |
FromAST CloudConfigYaml Source # | |
Defined in B9.Artifact.Content.CloudConfigYaml fromAST :: (IsB9 e, ToContentGenerator c) => AST c CloudConfigYaml -> Eff e CloudConfigYaml Source # |
Describe how to create structured content that has a tree-like syntactic
structure, e.g. yaml, JSON and erlang-proplists. The first parameter defines
a context into which the AST
is embedded,
e.g. B9.Artifact.Content'. The second parameter defines a specifix
syntax, e.g ErlangPropList
that the AST
value generates.
ASTObj [(String, AST c a)] | Create an object similar to a Json object. |
ASTArr [AST c a] | An array. |
ASTMerge [AST c a] | Merge the nested elements, this is a very powerful tool that allows to combine |
ASTEmbed c | |
ASTString String | |
ASTInt Int | |
ASTParse SourceFile | |
AST a |
Instances
parseFromTextWithErrorMessage Source #
:: (HasCallStack, Textual a) | |
=> String | An arbitrary string for error messages |
-> Text | |
-> Either String a |
Parse the given Text
. -- Return Left errorMessage
or Right a
.