Moduleghc-source-gen-0.4.6.0Haskell2010
GHC.SourceGen.Expr
This module provides combinators for constructing Haskell expressions.
- 2 types
- 17 values
- Packageghc-source-gen-0.4.6.0
- Exports19
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceExpr.hs
An overloaded label, as used with the OverloadedLabels extension.
#foo
=====
overLabel "foo"A MultiWayIf expression.
if | f x = "f"
| g x = "g"
| otherwise = "h"
=====
multiIf
[ guardedStmt (var "f" @@ var "x") $ rhs (string "f")
, guardedStmt (var "g" @@ var "x") $ rhs (string "g")
, guardedStmt (var "otherwise") $ rhs (string "h")
]A list comprehension expression.
[x * 2 | x <- [1 .. 10], even x]
=====
listComp (op (bvar "x") "*" (int 2))
[ bvar "x" <-- fromTo (int 1) (int 10)
, stmt $ var "even" @@ bvar "x"
]A type constraint on an expression.
e :: t
=====
var "e" @::@ var "t"Explicit type application.
f @ Int
=====
var "f" @@ var "Int"Constructs a record with explicit field names.
A { x = y }
=====
recordConE "A" [("x", var "y")]Updates a record expression with explicit field names.
r {a = b, c = d}
=====
recordUpd (var "x") [("a", var "b", ("c", var "d"))](f x) {a = b}
=====
recordUpd (var "f" @@ var "x") [("a", var "b")]f x {a = b} -- equivalent to f (x {a = b})
=====
var "f" @@ recordUpd (var "x") [("a", var "b")]An arithmetic sequence expression with a start value.
[a ..]
=====
from (var "a")An arithmetic sequence expression with a start and a step values.
[a, b ..]
=====
fromThen (var "a") (var "b")An arithmetic sequence expression with a start and an end values.
[a .. b]
=====
fromTo (var "a") (var "b")An arithmetic sequence expression with a start, a step, and an end values.
[a, b .. c]
=====
fromThenTo (var "a") (var "b") (var "c")