Safe Haskell | None |
---|---|
Language | Haskell2010 |
Documentation
astDeclarationsForLanguage :: Ptr Language -> FilePath -> Q [Dec] Source #
Derive Haskell datatypes from a language and its node-types.json
file.
Datatypes will be generated according to the specification in the node-types.json
file, with anonymous leaf types defined as synonyms for the Token
datatype.
Any datatypes among the node types which have already been defined in the module where the splice is run will be skipped, allowing customization of the representation of parts of the tree. Note that this should be used sparingly, as it imposes extra maintenance burden, particularly when the grammar is changed. This may be used to e.g. parse literals into Haskell equivalents (e.g. parsing the textual contents of integer literals into Integer
s), and may require defining UnmarshalAnn
or SymbolMatching
instances for (parts of) the custom datatypes, depending on where and how the datatype occurs in the generated tree, in addition to the usual Foldable
, Functor
, etc. instances provided for generated datatypes.