| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Language.Haskell.TH.Natural.Syntax.Case
Synopsis
- case_ :: GenExpr b => b -> CaseExprBuilder () -> Q CaseE
- type CaseExprBuilder = ConstBuilder CaseE
- matchConst :: (GenPat b1, GenExpr b2) => b1 -> b2 -> CaseExprBuilder ()
- matchWild :: GenExpr b => b -> CaseExprBuilder ()
- matchList :: GenExpr b => Int -> ([Exp] -> b) -> CaseExprBuilder ()
- matchCon :: Name -> ConMatchBuilder 'Empty 'Ready () -> CaseExprBuilder ()
- type ConMatchBuilder = Builder ConMatchBuilderState
- class ConPatternBuilder (m :: Type -> Type) where
- setFieldPattern :: Int -> Pat -> m ()
- field :: forall {k} s (step :: k) a. ConPatternBuilder (Builder s step step) => Int -> Pattern a -> Builder s step step a
- body :: GenExpr b => b -> ConMatchBuilder 'Empty 'Ready ()
- type PatternBuilder = ConstBuilder ConP
- data Pattern a
- var :: Pattern Exp
- constant :: GenPat b => b -> Pattern ()
- constructor :: Name -> (Int -> PatternBuilder a) -> Pattern a
- module Language.Haskell.TH.Natural.Syntax.Builder.Monad
Builder
case_ :: GenExpr b => b -> CaseExprBuilder () -> Q CaseE Source #
takes an expression to pattern match on and a CaseExprBuilder to produce a case expression
type CaseExprBuilder = ConstBuilder CaseE Source #
A builder for the matches and branches in a case expression
Match
matchConst :: (GenPat b1, GenExpr b2) => b1 -> b2 -> CaseExprBuilder () Source #
Match on a constant expression (e.g. a literal). The second argument is the body of the match.
matchWild :: GenExpr b => b -> CaseExprBuilder () Source #
Match using a wildcard pattern. The argument is the body of the match.
matchList :: GenExpr b => Int -> ([Exp] -> b) -> CaseExprBuilder () Source #
Match on a list of the given size.
The second argument is the body of the match, and its input is a list of VarE bound to each item in the list
matchCon :: Name -> ConMatchBuilder 'Empty 'Ready () -> CaseExprBuilder () Source #
Match using a constructor. The ConMatchBuilder allow deconstructing and accessing the fields of the constructor
Pattern match on constructors
Type
type ConMatchBuilder = Builder ConMatchBuilderState Source #
Builds a case match for a predefined constructor (see matchCon)
class ConPatternBuilder (m :: Type -> Type) where Source #
Methods
setFieldPattern :: Int -> Pat -> m () Source #
Instances
| ConPatternBuilder PatternBuilder Source # | |
Defined in Language.Haskell.TH.Natural.Syntax.Case Methods setFieldPattern :: Int -> Pat -> PatternBuilder () Source # | |
| ConPatternBuilder (ConMatchBuilder step step) Source # | |
Defined in Language.Haskell.TH.Natural.Syntax.Case Methods setFieldPattern :: Int -> Pat -> ConMatchBuilder step step () Source # | |
field :: forall {k} s (step :: k) a. ConPatternBuilder (Builder s step step) => Int -> Pattern a -> Builder s step step a Source #
In a pattern that deconstruct the value, this binds the field at the given index using the Pattern
Pattern Builder
Types
type PatternBuilder = ConstBuilder ConP Source #
Functions
constant :: GenPat b => b -> Pattern () Source #
Pattern-match a constructor's field to a constant (e.g. a literal)
constructor :: Name -> (Int -> PatternBuilder a) -> Pattern a Source #
Pattern-match a constructor's field On a nested constructor
The second argument is invoked for each field in the constructor