simple-templates-2.0.0: A basic template language for the Simple web framework
Safe HaskellTrustworthy
LanguageHaskell2010

Web.Simple.Templates.Types

Description

Types and helpers to encode the language AST

Synopsis

Documentation

newtype Function Source #

A funcation that's callable from inside a template

Constructors

Function 

Fields

class ToFunction a where Source #

Methods

toFunction :: a -> Function Source #

Instances

Instances details
FromJSON a => ToFunction (a -> Value) Source # 
Instance details

Defined in Web.Simple.Templates.Types

Methods

toFunction :: (a -> Value) -> Function Source #

(FromJSON a1, FromJSON a2) => ToFunction (a1 -> a2 -> Value) Source # 
Instance details

Defined in Web.Simple.Templates.Types

Methods

toFunction :: (a1 -> a2 -> Value) -> Function Source #

(FromJSON a1, FromJSON a2, FromJSON a3) => ToFunction (a1 -> a2 -> a3 -> Value) Source # 
Instance details

Defined in Web.Simple.Templates.Types

Methods

toFunction :: (a1 -> a2 -> a3 -> Value) -> Function Source #

(FromJSON a1, FromJSON a2, FromJSON a3, FromJSON a4) => ToFunction (a1 -> a2 -> a3 -> a4 -> Value) Source # 
Instance details

Defined in Web.Simple.Templates.Types

Methods

toFunction :: (a1 -> a2 -> a3 -> a4 -> Value) -> Function Source #

(FromJSON a1, FromJSON a2, FromJSON a3, FromJSON a4, FromJSON a5) => ToFunction (a1 -> a2 -> a3 -> a4 -> a5 -> Value) Source # 
Instance details

Defined in Web.Simple.Templates.Types

Methods

toFunction :: (a1 -> a2 -> a3 -> a4 -> a5 -> Value) -> Function Source #

(FromJSON a1, FromJSON a2, FromJSON a3, FromJSON a4, FromJSON a5, FromJSON a6) => ToFunction (a1 -> a2 -> a3 -> a4 -> a5 -> a6 -> Value) Source # 
Instance details

Defined in Web.Simple.Templates.Types

Methods

toFunction :: (a1 -> a2 -> a3 -> a4 -> a5 -> a6 -> Value) -> Function Source #

(FromJSON a1, FromJSON a2, FromJSON a3, FromJSON a4, FromJSON a5, FromJSON a6, FromJSON a7) => ToFunction (a1 -> a2 -> a3 -> a4 -> a5 -> a6 -> a7 -> Value) Source # 
Instance details

Defined in Web.Simple.Templates.Types

Methods

toFunction :: (a1 -> a2 -> a3 -> a4 -> a5 -> a6 -> a7 -> Value) -> Function Source #

(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) Source # 
Instance details

Defined in Web.Simple.Templates.Types

Methods

toFunction :: (a1 -> a2 -> a3 -> a4 -> a5 -> a6 -> a7 -> a8 -> Value) -> Function Source #

fromJSONStrict :: FromJSON a => Value -> a Source #

Like fromJSON but throws an error if there is a parse failure.

newtype Template Source #

A compiled template is a function that takes a FunctionMap and a global aeson Value and renders the template.

Constructors

Template 

Instances

Instances details
Monoid Template Source # 
Instance details

Defined in Web.Simple.Templates.Types

Semigroup Template Source # 
Instance details

Defined in Web.Simple.Templates.Types

type Identifier = Text Source #

A symbol identifier following the format [a-z][a-zA-Z0-9_-]*

data AST Source #

ASTs encode the various types of expressions in the language.

Constructors

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 (Maybe Identifier) Identifier AST AST (Maybe AST)

for([k,]v in expr) body separator

Instances

Instances details
Show AST Source # 
Instance details

Defined in Web.Simple.Templates.Types

Methods

showsPrec :: Int -> AST -> ShowS #

show :: AST -> String #

showList :: [AST] -> ShowS #

Eq AST Source # 
Instance details

Defined in Web.Simple.Templates.Types

Methods

(==) :: AST -> AST -> Bool #

(/=) :: AST -> AST -> Bool #

fromLiteral :: ToJSON a => a -> AST Source #

Lift a ToJSON to an ASTLiteral