A class for wrapping terms in parentheses.
Methods
par :: e -> e
:: a typeCtrl KGHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05
Moduleghc-source-gen-0.4.6.0Haskell2010
This module overloads some combinators so they can be used in different contexts: for expressions, types and/or patterns.
A class for wrapping terms in parentheses.
par :: e -> eA class for term application.
These functions may add additional parentheses to the AST. GHC's pretty-printing functions expect those parentheses to already be present, because GHC preserves parentheses when it parses the AST from a source file.
(@@) :: e -> e -> einfixl 2Prefix-apply a term:
f x
=====
var "f" @@ var "x"(+) x
=====
var "+" @@ var "x"Also parenthesizes the right-hand side in order to preserve its semantics when pretty-printed, but tries to do so only when necessary:
f x y
=====
var "f" @@ var "x" @@ var "y"
-- equivalently:
(var "f" @@ var "x") @@ var "y"f (g x)
=====
var "f" @@ (var "g" @@ var "x")f (g x)
=====
var "f" @@ par (var "g" @@ par (var "x"))op :: e -> RdrNameStr -> e -> eInfix-apply an operator or function.
For example:
x + y
=====
op (var "x") "+" (var "y")Also parenthesizes the right-hand side in order to preserve its semantics when pretty-printed, but tries to do so only when necessary:
f x + g y
=====
op (var "f" @@ var "x") "+" (var "g" @@ var "y")x + (y + z)
=====
op (var "x") "+" (op (var "y") "+" (var "z"))f x `plus` g y
=====
op (var "f" @@ var "x") "plus" (var "g" @@ var "y")An explicit list of terms.
[x, y]
=====
list [var "x", var "y"]NOTE: for types, use either listTy or promotedListTy.
Terms that can contain references to named things. They may be actual variables,
functions, or constructors. For example, var "a" and var "A"
are equally valid.
Depending on the context, the former could refer to either a function,
value, type variable, or pattern; and the latter could refer to either a type
constructor or a data constructor,
var :: RdrNameStr -> aTerms that can contain references to locally-bound variables.
Depending on the context, bvar "a" could refer to either a
pattern variable or a type variable.
bvar :: OccNameStr -> aBVar HsExpr'Defined in ghc-source-gen-0.4.6.0 · GHC.SourceGen.OverloadedBVar HsTyVarBndr'Defined in ghc-source-gen-0.4.6.0 · GHC.SourceGen.OverloadedBVar HsTyVarBndrS'Defined in ghc-source-gen-0.4.6.0 · GHC.SourceGen.OverloadedBVar HsType'Defined in ghc-source-gen-0.4.6.0 · GHC.SourceGen.OverloadedBVar IE'Defined in ghc-source-gen-0.4.6.0 · GHC.SourceGen.OverloadedBVar Pat'Defined in ghc-source-gen-0.4.6.0 · GHC.SourceGen.Overloaded