Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module provides combinators for constructing Haskell expressions.
Synopsis
- type HsExpr' = HsExpr GhcPs
- overLabel :: String -> HsExpr'
- let' :: [RawValBind] -> HsExpr' -> HsExpr'
- case' :: HsExpr' -> [RawMatch] -> HsExpr'
- lambda :: [Pat'] -> HsExpr' -> HsExpr'
- lambdaCase :: [RawMatch] -> HsExpr'
- if' :: HsExpr' -> HsExpr' -> HsExpr' -> HsExpr'
- multiIf :: [GuardedExpr] -> HsExpr'
- do' :: [Stmt'] -> HsExpr'
- listComp :: HsExpr' -> [Stmt'] -> HsExpr'
- type Stmt' = Stmt GhcPs LHsExpr'
- (@::@) :: HsExpr' -> HsType' -> HsExpr'
- tyApp :: HsExpr' -> HsType' -> HsExpr'
- recordConE :: RdrNameStr -> [(RdrNameStr, HsExpr')] -> HsExpr'
- recordUpd :: HsExpr' -> [(RdrNameStr, HsExpr')] -> HsExpr'
- from :: HsExpr' -> HsExpr'
- fromThen :: HsExpr' -> HsExpr' -> HsExpr'
- fromTo :: HsExpr' -> HsExpr' -> HsExpr'
- fromThenTo :: HsExpr' -> HsExpr' -> HsExpr' -> HsExpr'
Documentation
overLabel :: String -> HsExpr' Source #
An overloaded label, as used with the OverloadedLabels
extension.
#foo ===== overLabel "foo"
lambdaCase :: [RawMatch] -> HsExpr' Source #
multiIf :: [GuardedExpr] -> HsExpr' Source #
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") ]
listComp :: HsExpr' -> [Stmt'] -> HsExpr' Source #
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" ]
(@::@) :: HsExpr' -> HsType' -> HsExpr' Source #
A type constraint on an expression.
e :: t ===== var "e" @::@ var "t"
tyApp :: HsExpr' -> HsType' -> HsExpr' Source #
Explicit type application.
f @ Int ===== var "f" @@ var "Int"
recordConE :: RdrNameStr -> [(RdrNameStr, HsExpr')] -> HsExpr' Source #
Constructs a record with explicit field names.
A { x = y } ===== recordConE "A" [("x", var "y")]
recordUpd :: HsExpr' -> [(RdrNameStr, HsExpr')] -> HsExpr' Source #
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")]
from :: HsExpr' -> HsExpr' Source #
An arithmetic sequence expression with a start value.
[a ..] ===== from (var "a")
fromThen :: HsExpr' -> HsExpr' -> HsExpr' Source #
An arithmetic sequence expression with a start and a step values.
[a, b ..] ===== fromThen (var "a") (var "b")