Copyright | (c) The GHC Team 1997-2000 (c) Niklas Broberg 2004 |
---|---|
License | BSD-style (see the file LICENSE.txt) |
Maintainer | Niklas Broberg, d00nibro@chalmers.se |
Stability | experimental |
Portability | portable |
Safe Haskell | Safe |
Language | Haskell98 |
This module contains combinators to use when building Haskell source trees programmatically, as opposed to parsing them from a string. The contents here are quite experimental and will likely receive a lot of attention when the rest has stabilised.
- name :: String -> Name ()
- sym :: String -> Name ()
- var :: Name () -> Exp ()
- op :: Name () -> QOp ()
- qvar :: ModuleName () -> Name () -> Exp ()
- pvar :: Name () -> Pat ()
- app :: Exp () -> Exp () -> Exp ()
- infixApp :: Exp () -> QOp () -> Exp () -> Exp ()
- appFun :: Exp () -> [Exp ()] -> Exp ()
- pApp :: Name () -> [Pat ()] -> Pat ()
- tuple :: [Exp ()] -> Exp ()
- pTuple :: [Pat ()] -> Pat ()
- varTuple :: [Name ()] -> Exp ()
- pvarTuple :: [Name ()] -> Pat ()
- function :: String -> Exp ()
- strE :: String -> Exp ()
- charE :: Char -> Exp ()
- intE :: Integer -> Exp ()
- strP :: String -> Pat ()
- charP :: Char -> Pat ()
- intP :: Integer -> Pat ()
- doE :: [Stmt ()] -> Exp ()
- lamE :: [Pat ()] -> Exp () -> Exp ()
- letE :: [Decl ()] -> Exp () -> Exp ()
- caseE :: Exp () -> [Alt ()] -> Exp ()
- alt :: Pat () -> Exp () -> Alt ()
- altGW :: Pat () -> [Stmt ()] -> Exp () -> Binds () -> Alt ()
- listE :: [Exp ()] -> Exp ()
- eList :: Exp ()
- peList :: Pat ()
- paren :: Exp () -> Exp ()
- pParen :: Pat () -> Pat ()
- qualStmt :: Exp () -> Stmt ()
- genStmt :: Pat () -> Exp () -> Stmt ()
- letStmt :: [Decl ()] -> Stmt ()
- binds :: [Decl ()] -> Binds ()
- noBinds :: Maybe (Binds ())
- wildcard :: Pat ()
- genNames :: String -> Int -> [Name ()]
- sfun :: Name () -> [Name ()] -> Rhs () -> Maybe (Binds ()) -> Decl ()
- simpleFun :: Name () -> Name () -> Exp () -> Decl ()
- patBind :: Pat () -> Exp () -> Decl ()
- patBindWhere :: Pat () -> Exp () -> [Decl ()] -> Decl ()
- nameBind :: Name () -> Exp () -> Decl ()
- metaFunction :: String -> [Exp ()] -> Exp ()
- metaConPat :: String -> [Pat ()] -> Pat ()
Syntax building functions
name :: String -> Name () Source #
An identifier with the given string as its name. The string should be a valid Haskell identifier.
sym :: String -> Name () Source #
A symbol identifier. The string should be a valid Haskell symbol identifier.
doE :: [Stmt ()] -> Exp () Source #
A do block formed by the given statements.
The last statement in the list should be
a Qualifier
expression.
lamE :: [Pat ()] -> Exp () -> Exp () Source #
Lambda abstraction, given a list of argument patterns and an expression body.
altGW :: Pat () -> [Stmt ()] -> Exp () -> Binds () -> Alt () Source #
An alternative with a single guard in a case
expression.
genNames :: String -> Int -> [Name ()] Source #
Generate k names by appending numbers 1 through k to a given string.
More advanced building
sfun :: Name () -> [Name ()] -> Rhs () -> Maybe (Binds ()) -> Decl () Source #
A function with a single clause
simpleFun :: Name () -> Name () -> Exp () -> Decl () Source #
A function with a single clause, a single argument, no guards and no where declarations
patBind :: Pat () -> Exp () -> Decl () Source #
A pattern bind where the pattern is a variable, and where there are no guards and no 'where' clause.
patBindWhere :: Pat () -> Exp () -> [Decl ()] -> Decl () Source #
A pattern bind where the pattern is a variable, and where there are no guards, but with a 'where' clause.