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

Safe HaskellNone
LanguageHaskell2010

GHC.SourceGen.Overloaded

Description

This module overloads some combinators so they can be used in different contexts: for expressions, types and/or patterns.

Synopsis

Documentation

class Par e where Source #

A class for wrapping terms in parentheses.

Methods

par :: e -> e Source #

Instances
Par Pat' Source # 
Instance details

Defined in GHC.SourceGen.Overloaded

Methods

par :: Pat' -> Pat' Source #

Par HsType' Source # 
Instance details

Defined in GHC.SourceGen.Overloaded

Methods

par :: HsType' -> HsType' Source #

Par HsExpr' Source # 
Instance details

Defined in GHC.SourceGen.Overloaded

Methods

par :: HsExpr' -> HsExpr' Source #

class App e where Source #

A 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.

Methods

(@@) :: e -> e -> e infixl 2 Source #

Prefix-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 -> e Source #

Infix-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")
Instances
App HsType' Source # 
Instance details

Defined in GHC.SourceGen.Overloaded

App HsExpr' Source # 
Instance details

Defined in GHC.SourceGen.Overloaded

class HasTuple e where Source #

Methods

unit :: e Source #

tupleOf :: Boxity -> [e] -> e Source #

Instances
HasTuple Pat' Source # 
Instance details

Defined in GHC.SourceGen.Overloaded

Methods

unit :: Pat' Source #

tupleOf :: Boxity -> [Pat'] -> Pat' Source #

HasTuple HsType' Source # 
Instance details

Defined in GHC.SourceGen.Overloaded

HasTuple HsExpr' Source # 
Instance details

Defined in GHC.SourceGen.Overloaded

tuple :: HasTuple e => [e] -> e Source #

unboxedTuple :: HasTuple e => [e] -> e Source #

class HasList e where Source #

An explicit list of terms.

[x, y]
=====
list [var "x", var "y"]

NOTE: for types, use either listTy or promotedListTy.

Methods

list :: [e] -> e Source #

nil :: e Source #

The empty list [].

cons :: e Source #

The list cons constructor (:).

Instances
HasList Pat' Source # 
Instance details

Defined in GHC.SourceGen.Overloaded

HasList HsExpr' Source # 
Instance details

Defined in GHC.SourceGen.Overloaded

class Var a where Source #

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,

Methods

var :: RdrNameStr -> a Source #

Instances
Var IE' Source # 
Instance details

Defined in GHC.SourceGen.Overloaded

Methods

var :: RdrNameStr -> IE' Source #

Var HsTyVarBndr' Source # 
Instance details

Defined in GHC.SourceGen.Overloaded

Var Pat' Source # 
Instance details

Defined in GHC.SourceGen.Overloaded

Methods

var :: RdrNameStr -> Pat' Source #

Var HsType' Source # 
Instance details

Defined in GHC.SourceGen.Overloaded

Var HsExpr' Source # 
Instance details

Defined in GHC.SourceGen.Overloaded