Safe Haskell | Trustworthy |
---|
Types and helpers to encode the language AST
- newtype Function = Function {}
- class ToFunction a where
- toFunction :: a -> Function
- fromJSONStrict :: FromJSON a => Value -> a
- type FunctionMap = HashMap Identifier Function
- newtype Template = Template {
- renderTemplate :: FunctionMap -> Value -> Text
- type Identifier = Text
- data AST
- fromLiteral :: ToJSON a => a -> AST
- astListToArray :: [AST] -> AST
Documentation
A funcation that's callable from inside a template
class ToFunction a whereSource
toFunction :: a -> FunctionSource
(FromJSON a1, FromJSON a2, FromJSON a3, FromJSON a4, FromJSON a5, FromJSON a6, FromJSON a7, FromJSON a8) => ToFunction (a1 -> a2 -> a3 -> a4 -> a5 -> a6 -> a7 -> a8 -> Value) | |
(FromJSON a1, FromJSON a2, FromJSON a3, FromJSON a4, FromJSON a5, FromJSON a6, FromJSON a7) => ToFunction (a1 -> a2 -> a3 -> a4 -> a5 -> a6 -> a7 -> Value) | |
(FromJSON a1, FromJSON a2, FromJSON a3, FromJSON a4, FromJSON a5, FromJSON a6) => ToFunction (a1 -> a2 -> a3 -> a4 -> a5 -> a6 -> Value) | |
(FromJSON a1, FromJSON a2, FromJSON a3, FromJSON a4, FromJSON a5) => ToFunction (a1 -> a2 -> a3 -> a4 -> a5 -> Value) | |
(FromJSON a1, FromJSON a2, FromJSON a3, FromJSON a4) => ToFunction (a1 -> a2 -> a3 -> a4 -> Value) | |
(FromJSON a1, FromJSON a2, FromJSON a3) => ToFunction (a1 -> a2 -> a3 -> Value) | |
(FromJSON a1, FromJSON a2) => ToFunction (a1 -> a2 -> Value) | |
FromJSON a => ToFunction (a -> Value) |
fromJSONStrict :: FromJSON a => Value -> aSource
Like fromJSON
but throws an error if there is a parse failure.
A compiled template is a function that takes a FunctionMap
and a global
aeson Value
and renders the template.
Template | |
|
type Identifier = TextSource
A symbol identifier following the format [a-z][a-zA-Z0-9_-]*
AST
s encode the various types of expressions in the language.
ASTRoot [AST] | A series of sub-ASTs |
ASTLiteral Value | A literal that does not require evaluation |
ASTFunc Identifier [AST] | A function call and list of arguments |
ASTVar Identifier | Variable dereference |
ASTIndex AST [Identifier] | Nested index into an object |
ASTArray (Vector AST) | A literal array (may contain non-literals) |
ASTIf AST AST (Maybe AST) | If - condition, true branch and optional false branch |
ASTFor Identifier AST AST (Maybe AST) | for(i in expr) body separator |
fromLiteral :: ToJSON a => a -> ASTSource
Lift a ToJSON
to an ASTLiteral
astListToArray :: [AST] -> ASTSource