template-haskell-natural-1.0.0.0
Safe HaskellNone
LanguageHaskell2010

Language.Haskell.TH.Natural.Syntax.Expr.Untyped.Class

Synopsis

Documentation

class IsExprBuilder st where Source #

Typeclass to factorise the common behaviour of expression builders

Associated Types

type Definition st Source #

Methods

addDeconstruct :: forall (step :: BuilderStep). Deconstruct -> Builder st step 'Empty () Source #

addLet :: forall (step :: BuilderStep). Binding -> Builder st step 'Empty () Source #

letCount :: forall {k} (step :: k). Builder st step step Int Source #

returns :: forall b (step :: BuilderStep). GenExpr b => b -> Builder st step 'Ready () Source #

runExprBuilder :: forall (step :: BuilderStep). Builder st step 'Ready () -> Definition st Source #

Instances

Instances details
IsExprBuilder DoExprBuilderState Source # 
Instance details

Defined in Language.Haskell.TH.Natural.Syntax.Expr.Do.Untyped

IsExprBuilder SimpleExprBuilderState Source # 
Instance details

Defined in Language.Haskell.TH.Natural.Syntax.Expr.Simple.Untyped

Let

letBind :: forall st b (step :: BuilderStep). (IsExprBuilder st, GenExpr b) => b -> Builder st step 'Empty Exp Source #

Let-Bind an expression

strictLetBind :: forall st b (step :: BuilderStep). (IsExprBuilder st, GenExpr b) => b -> Builder st step 'Empty Exp Source #

Let-Bind an expression with a strict pattern

letBind_ :: forall st b (step :: BuilderStep). (IsExprBuilder st, GenExpr b) => Bool -> b -> Builder st step 'Empty Exp Source #

Deconstruction

getField Source #

Arguments

:: forall st b (step :: BuilderStep). (IsExprBuilder st, GenExpr b) 
=> Name

Constructor name

-> Int

index of the field

-> b

Expr to deconstruct

-> Builder st step 'Empty Exp 

Deconstruct a value and get the nth field of the constructor

getTupleField Source #

Arguments

:: forall st b (step :: BuilderStep). (IsExprBuilder st, GenExpr b) 
=> Int

Tuple size

-> Int

Field Index

-> b 
-> Builder st step 'Empty Exp 

Like getField, but for tuples

getFields Source #

Arguments

:: forall st b (step :: BuilderStep). (IsExprBuilder st, GenExpr b) 
=> Name 
-> Int

Field count

-> b 
-> Builder st step 'Empty [Exp] 

Deconstruct and get all the fields in the constructor

getTupleFields Source #

Arguments

:: forall st b (step :: BuilderStep). (IsExprBuilder st, GenExpr b) 
=> Int

Tuple size

-> b 
-> Builder st step 'Empty [Exp] 

Same as getFields, but for tuples

getField' :: forall st b (step :: BuilderStep). (IsExprBuilder st, GenExpr b) => Name -> Int -> b -> (Pat -> Q Pat) -> Builder st step 'Empty Exp Source #

Same as getField, but allow customising the bound pattern

getField_ Source #

Arguments

:: forall st b (step :: BuilderStep). (IsExprBuilder st, GenExpr b) 
=> Name 
-> Int

The index of the field to get

-> Int

The number of fields in the constructor

-> b 
-> Builder st step 'Empty Exp 

Similar to getField. Useful when the constructor to use isn't accessible through reify

getTupleField' Source #

Arguments

:: forall st b (step :: BuilderStep). (IsExprBuilder st, GenExpr b) 
=> Int

Tuple size

-> Int

Field Index

-> b 
-> (Pat -> Q Pat) 
-> Builder st step 'Empty Exp 

Like 'getField'', but for tuples

getField'' Source #

Arguments

:: forall st b (step :: BuilderStep). (IsExprBuilder st, GenExpr b) 
=> Either Int Name

The constructor used to deconstruct

-> Int

The index of the field in the constructor

-> Maybe Int

The number of fields in the constructor, if known | The expression to deconstruct

-> b 
-> (Pat -> Q Pat)

Modify the created pattern (e.g. add BangP or type annotation)

-> Builder st step 'Empty Exp 

strict :: Pat -> Q Pat Source #

Util for 'getField'' to set the pattern as strict

Orphan instances

(IsExprBuilder st, GenExpr (Definition st)) => GenExpr (Builder st step 'Ready ()) Source # 
Instance details

Methods

genExpr :: Builder st step 'Ready () -> Q Exp Source #