purescript-0.3.12: PureScript Programming Language Compiler

Safe HaskellNone



Data types for values, statements, binders and do notation



type Guard = ValueSource

A guard is just a boolean-valued expression that appears alongside a set of binders

data Value Source

Data type for values


NumericLiteral (Either Integer Double)

A numeric literal

StringLiteral String

A string literal

BooleanLiteral Bool

A boolean literal

BinaryNoParens (Qualified Ident) Value Value

Binary operator application. During the rebracketing phase of desugaring, this data constructor will be removed.

Parens Value

Explicit parentheses. During the rebracketing phase of desugaring, this data constructor will be removed.

ArrayLiteral [Value]

An array literal

ObjectLiteral [(String, Value)]

An object literal

Accessor String Value

An record property accessor expression

ObjectUpdate Value [(String, Value)]

Partial record update

Abs Ident Value

Function introduction

App Value Value

Function application

Var (Qualified Ident)


IfThenElse Value Value Value

Conditional (if-then-else expression)

Block [Statement]

A "Block" i.e. a collection of statements which evaluate to a value

Constructor (Qualified ProperName)

A data constructor

Case [Value] [([Binder], Maybe Guard, Value)]

A case expression. During the case expansion phase of desugaring, top-level binders will get desugared into case expressions, hence the need for guards and multiple binders per branch here.

TypedValue Bool Value Type

A value with a type annotation

Do [DoNotationElement]

A do-notation block

TypeClassDictionary (Qualified ProperName, Type) [TypeClassDictionaryInScope]

A placeholder for a type class dictionary to be inserted later. At the end of type checking, these placeholders will be replaced with actual expressions representing type classes dictionaries which can be evaluated at runtime. The constructor arguments represent (in order): the type class name and instance type, and the type class dictionaries in scope.

data TypeClassDictionaryType Source

The type of a type class dictionary



A regular type class dictionary

TCDAlias (Qualified Ident)

A type class dictionary which is an alias for an imported dictionary from another module

data TypeClassDictionaryInScope Source

Data representing a type class dictionary which is in scope




tcdName :: Qualified Ident

The identifier with which the dictionary can be accessed at runtime

tcdClassName :: Qualified ProperName

The name of the type class to which this type class instance applies

tcdInstanceType :: Type

The type to which this type class instance applies

tcdDependencies :: Maybe [(Qualified ProperName, Type)]

Type class dependencies which must be satisfied to construct this dictionary

tcdType :: TypeClassDictionaryType

The type of this dictionary

data DoNotationElement Source

A statement in a do-notation block


DoNotationValue Value

A monadic value without a binder

DoNotationBind Binder Value

A monadic value with a binder

DoNotationLet Binder Value

A let statement, i.e. a pure value with a binder

data Statement Source

Data type for statements which can appear inside a Block expression


VariableIntroduction Ident Value

A variable introduction and initial assignment

Assignment Ident Value

A variable reassignment

While Value [Statement]

A while loop

For Ident Value Value [Statement]

A for loop

If IfStatement

An if-then-else statement

Return Value

A return statement

data IfStatement Source

Data type for if-statements


IfStatement Value [Statement] (Maybe ElseStatement)

An if statement. Arguments are (in order): boolean condition, true branch, optional else branch.

data ElseStatement Source

Data type for the else branch in an if-statement


Else [Statement]

An else branch

ElseIf IfStatement

An else-if branch

data Binder Source

Data type for binders



Wildcard binder

BooleanBinder Bool

A binder which matches a boolean literal

StringBinder String

A binder which matches a string literal

NumberBinder (Either Integer Double)

A binder which matches a numeric literal

VarBinder Ident

A binder which binds an identifier

NullaryBinder (Qualified ProperName)

A binder which matches a data constructor with no argument

UnaryBinder (Qualified ProperName) Binder

A binder which matches a data constructor with one argument

ObjectBinder [(String, Binder)]

A binder which matches a record and binds its properties

ArrayBinder [Binder]

A binder which matches an array and binds its elements

ConsBinder Binder Binder

A binder which matches an array and binds its head and tail

NamedBinder Ident Binder

A binder which binds its input to an identifier