HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulehaskell-src-exts-1.23.1Haskell98

Language.Haskell.Exts.Build

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.

  • 46 values

Syntax building functions

39 declarations
valuename :: String -> Name ()
#

An identifier with the given string as its name. The string should be a valid Haskell identifier.

valuesym :: String -> Name ()
#

A symbol identifier. The string should be a valid Haskell symbol identifier.

valuevar :: Name () -> Exp ()
#

A local variable as expression.

valueop :: Name () -> QOp ()
#

Use the given identifier as an operator.

valueapp :: Exp () -> Exp () -> Exp ()
#

Application of expressions by juxtaposition.

valueappFun :: Exp () -> [Exp ()] -> Exp ()
#

Apply a function to a list of arguments.

valuepApp :: Name () -> [Pat ()] -> Pat ()
#

A constructor pattern, with argument patterns.

valuevarTuple :: [Name ()] -> Exp ()
#

A tuple expression consisting of variables only.

valuepvarTuple :: [Name ()] -> Pat ()
#

A tuple pattern consisting of variables only.

valuecharE :: Char -> Exp ()
#

A literal character expression.

valuedoE :: [Stmt ()] -> Exp ()
#

A do block formed by the given statements. The last statement in the list should be a Qualifier expression.

valuelamE :: [Pat ()] -> Exp () -> Exp ()
#

Lambda abstraction, given a list of argument patterns and an expression body.

valuealt :: Pat () -> Exp () -> Alt ()
#

An unguarded alternative in a case expression.

valuealtGW :: Pat () -> [Stmt ()] -> Exp () -> Binds () -> Alt ()
#

An alternative with a single guard in a case expression.

valueeList :: Exp ()
#

The empty list expression.

valuepeList :: Pat ()
#

The empty list pattern.

valueparen :: Exp () -> Exp ()
#

Put parentheses around an expression.

valuepParen :: Pat () -> Pat ()
#

Put parentheses around a pattern.

valuebinds :: [Decl ()] -> Binds ()
#

Hoist a set of declarations to a binding group.

valuegenNames :: String -> Int -> [Name ()]
#

Generate k names by appending numbers 1 through k to a given string.

More advanced building

7 declarations
valuesimpleFun :: Name () -> Name () -> Exp () -> Decl ()
#

A function with a single clause, a single argument, no guards and no where declarations

valuepatBind :: Pat () -> Exp () -> Decl ()
#

A pattern bind where the pattern is a variable, and where there are no guards and no where clause.

valuepatBindWhere :: Pat () -> Exp () -> [Decl ()] -> Decl ()
#

A pattern bind where the pattern is a variable, and where there are no guards, but with a where clause.

valuemetaConPat :: String -> [Pat ()] -> Pat ()
#

Apply a constructor of a given name to a list of pattern arguments, forming a constructor pattern.