ghc-source-gen-0.4.3.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

Instances details
Par HsExpr' Source # 
Instance details

Defined in GHC.SourceGen.Overloaded

Methods

par :: HsExpr' -> HsExpr' Source #

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 #

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

Instances details
App HsExpr' Source # 
Instance details

Defined in GHC.SourceGen.Overloaded

App HsType' Source # 
Instance details

Defined in GHC.SourceGen.Overloaded

class HasTuple e where Source #

Methods

unit :: e Source #

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

Instances

Instances details
HasTuple HsExpr' Source # 
Instance details

Defined in GHC.SourceGen.Overloaded

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

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

Instances details
HasList HsExpr' Source # 
Instance details

Defined in GHC.SourceGen.Overloaded

HasList Pat' Source # 
Instance details

Defined in GHC.SourceGen.Overloaded

class BVar a => 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

Instances details
Var IE' Source # 
Instance details

Defined in GHC.SourceGen.Overloaded

Methods

var :: RdrNameStr -> IE' Source #

Var HsExpr' Source # 
Instance details

Defined in GHC.SourceGen.Overloaded

Var HsType' Source # 
Instance details

Defined in GHC.SourceGen.Overloaded

class BVar a where Source #

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

Methods

bvar :: OccNameStr -> a Source #

Instances

Instances details
BVar HsTyVarBndr' Source # 
Instance details

Defined in GHC.SourceGen.Overloaded

BVar IE' Source # 
Instance details

Defined in GHC.SourceGen.Overloaded

Methods

bvar :: OccNameStr -> IE' Source #

BVar HsExpr' Source # 
Instance details

Defined in GHC.SourceGen.Overloaded

BVar Pat' Source # 
Instance details

Defined in GHC.SourceGen.Overloaded

Methods

bvar :: OccNameStr -> Pat' Source #

BVar HsType' Source # 
Instance details

Defined in GHC.SourceGen.Overloaded