ghc-source-gen-0.1.0.0: Constructs Haskell syntax trees for the GHC API.

Safe HaskellNone
LanguageHaskell2010

GHC.SourceGen.Expr

Description

This module provides combinators for constructing Haskell expressions.

Synopsis

Documentation

overLabel :: String -> HsExpr' Source #

An overloaded label, as used with the OverloadedLabels extension.

#foo
=====
overLabel "foo"

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")
    ]

do' :: [Stmt'] -> HsExpr' Source #

A do-expression.

Individual statements may be constructed with <-- and/or stmt.

do
  x <- act
  return x
=====
do' [var "x" <-- var "act", stmt $ var "return" @@ var "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"