haskell-src-exts-1.17.1: Manipulating Haskell source: abstract syntax, lexer, parser, and pretty-printer

Copyright(c) Niklas Broberg 2004-2009, (c) The GHC Team, 1997-2000
LicenseBSD-style (see the file LICENSE.txt)
MaintainerNiklas Broberg, d00nibro@chalmers.se
Stabilitystable
Portabilityportable
Safe HaskellSafe
LanguageHaskell98

Language.Haskell.Exts.Annotated.Syntax

Contents

Description

A suite of datatypes describing the (semi-concrete) abstract syntax of Haskell 98 http://www.haskell.org/onlinereport/ plus registered extensions, including:

  • multi-parameter type classes with functional dependencies (MultiParamTypeClasses, FunctionalDependencies)
  • parameters of type class assertions are unrestricted (FlexibleContexts)
  • forall types as universal and existential quantification (RankNTypes, ExistentialQuantification, etc)
  • pattern guards (PatternGuards)
  • implicit parameters (ImplicitParameters)
  • generalised algebraic data types (GADTs)
  • template haskell (TemplateHaskell)
  • empty data type declarations (EmptyDataDecls)
  • unboxed tuples (UnboxedTuples)
  • regular patterns (RegularPatterns)
  • HSP-style XML expressions and patterns (XmlSyntax)

All nodes in the syntax tree are annotated with something of a user-definable data type. When parsing, this annotation will contain information about the source location that the particular node comes from.

Synopsis

Modules

data Module l Source

A complete Haskell source module.

Constructors

Module l (Maybe (ModuleHead l)) [ModulePragma l] [ImportDecl l] [Decl l]

an ordinary Haskell module

XmlPage l (ModuleName l) [ModulePragma l] (XName l) [XAttr l] (Maybe (Exp l)) [Exp l]

a module consisting of a single XML document. The ModuleName never appears in the source but is needed for semantic purposes, it will be the same as the file name.

XmlHybrid l (Maybe (ModuleHead l)) [ModulePragma l] [ImportDecl l] [Decl l] (XName l) [XAttr l] (Maybe (Exp l)) [Exp l]

a hybrid module combining an XML document with an ordinary module

data WarningText l Source

Warning text to optionally use in the module header of e.g. a deprecated module.

Constructors

DeprText l String 
WarnText l String 

data ExportSpec l Source

An item in a module's export specification.

Constructors

EVar l (QName l)

variable.

EAbs l (Namespace l) (QName l)

T: a class or datatype exported abstractly, or a type synonym.

EThingAll l (QName l)

T(..): a class exported with all of its methods, or a datatype exported with all of its constructors.

EThingWith l (QName l) [CName l]

T(C_1,...,C_n): a class exported with some of its methods, or a datatype exported with some of its constructors.

EModuleContents l (ModuleName l)

module M: re-export a module.

data ImportDecl l Source

An import declaration.

Constructors

ImportDecl 

Fields

importAnn :: l

annotation, used by parser for position of the import keyword.

importModule :: ModuleName l

name of the module imported.

importQualified :: Bool

imported qualified?

importSrc :: Bool

imported with {-# SOURCE #-}?

importSafe :: Bool

Import safe?

importPkg :: Maybe String

imported with explicit package name

importAs :: Maybe (ModuleName l)

optional alias name in an as clause.

importSpecs :: Maybe (ImportSpecList l)

optional list of import specifications.

data ImportSpec l Source

An import specification, representing a single explicit item imported (or hidden) from a module.

Constructors

IVar l (Name l)

variable

IAbs l (Namespace l) (Name l)

T: the name of a class, datatype or type synonym.

IThingAll l (Name l)

T(..): a class imported with all of its methods, or a datatype imported with all of its constructors.

IThingWith l (Name l) [CName l]

T(C_1,...,C_n): a class imported with some of its methods, or a datatype imported with some of its constructors.

data Assoc l Source

Associativity of an operator.

Constructors

AssocNone l

non-associative operator (declared with infix)

AssocLeft l

left-associative operator (declared with infixl).

AssocRight l

right-associative operator (declared with infixr)

Declarations

data Decl l Source

A top-level declaration.

Constructors

TypeDecl l (DeclHead l) (Type l)

A type declaration

TypeFamDecl l (DeclHead l) (Maybe (Kind l))

A type family declaration

ClosedTypeFamDecl l (DeclHead l) (Maybe (Kind l)) [TypeEqn l]

A closed type family declaration

DataDecl l (DataOrNew l) (Maybe (Context l)) (DeclHead l) [QualConDecl l] (Maybe (Deriving l))

A data OR newtype declaration

GDataDecl l (DataOrNew l) (Maybe (Context l)) (DeclHead l) (Maybe (Kind l)) [GadtDecl l] (Maybe (Deriving l))

A data OR newtype declaration, GADT style

DataFamDecl l (Maybe (Context l)) (DeclHead l) (Maybe (Kind l))

A data family declaration

TypeInsDecl l (Type l) (Type l)

A type family instance declaration

DataInsDecl l (DataOrNew l) (Type l) [QualConDecl l] (Maybe (Deriving l))

A data family instance declaration

GDataInsDecl l (DataOrNew l) (Type l) (Maybe (Kind l)) [GadtDecl l] (Maybe (Deriving l))

A data family instance declaration, GADT style

ClassDecl l (Maybe (Context l)) (DeclHead l) [FunDep l] (Maybe [ClassDecl l])

A declaration of a type class

InstDecl l (Maybe (Overlap l)) (InstRule l) (Maybe [InstDecl l])

An declaration of a type class instance

DerivDecl l (Maybe (Overlap l)) (InstRule l)

A standalone deriving declaration

InfixDecl l (Assoc l) (Maybe Int) [Op l]

A declaration of operator fixity

DefaultDecl l [Type l]

A declaration of default types

SpliceDecl l (Exp l)

A Template Haskell splicing declaration

TypeSig l [Name l] (Type l)

A type signature declaration

PatSynSig l (Name l) (Maybe [TyVarBind l]) (Maybe (Context l)) (Maybe (Context l)) (Type l)

A pattern synonym signature declation

FunBind l [Match l]

A set of function binding clauses

PatBind l (Pat l) (Rhs l) (Maybe (Binds l))

A pattern binding

PatSyn l (Pat l) (Pat l) (PatternSynDirection l)

A pattern synonym binding

ForImp l (CallConv l) (Maybe (Safety l)) (Maybe String) (Name l) (Type l)

A foreign import declaration

ForExp l (CallConv l) (Maybe String) (Name l) (Type l)

A foreign export declaration

RulePragmaDecl l [Rule l]

A RULES pragma

DeprPragmaDecl l [([Name l], String)]

A DEPRECATED pragma

WarnPragmaDecl l [([Name l], String)]

A WARNING pragma

InlineSig l Bool (Maybe (Activation l)) (QName l)

An INLINE pragma

InlineConlikeSig l (Maybe (Activation l)) (QName l)

An INLINE CONLIKE pragma

SpecSig l (Maybe (Activation l)) (QName l) [Type l]

A SPECIALISE pragma

SpecInlineSig l Bool (Maybe (Activation l)) (QName l) [Type l]

A SPECIALISE INLINE pragma

InstSig l (InstRule l)

A SPECIALISE instance pragma

AnnPragma l (Annotation l)

An ANN pragma

MinimalPragma l (Maybe (BooleanFormula l))

A MINIMAL pragma

RoleAnnotDecl l (QName l) [Role l]

A role annotation

data DeclHead l Source

The head of a type or class declaration, which consists of the type or class name applied to some type variables

class C a b is represented as

DHApp
   ()
   (DHApp
      () (DHead () (Ident () "C")) (UnkindedVar () (Ident () "a")))
   (UnkindedVar () (Ident () "b"))

(where the annotation type l is instantiated with ())

class (a :< b) c is represented as

DHApp
   ()
   (DHParen
      ()
      (DHApp
         ()
         (DHInfix () (UnkindedVar () (Ident () "a")) (Symbol () ":<"))
         (UnkindedVar () (Ident () "b"))))
   (UnkindedVar () (Ident () "c"))

Constructors

DHead l (Name l)

type or class name

DHInfix l (TyVarBind l) (Name l)

infix application of the type/class name to the left operand

DHParen l (DeclHead l)

parenthesized declaration head

DHApp l (DeclHead l) (TyVarBind l)

application to one more type variable

data InstRule l Source

The instance declaration rule, which is, roughly, the part of the instance declaration before the where keyword.

Example: instance Ord a => Ord (Maybe a) is represented as

IRule
   ()
   Nothing
   (Just
      (CxSingle
         ()
         (ClassA
            () (UnQual () (Ident () "Ord")) [ TyVar () (Ident () "a") ])))
   (IHApp
      ()
      (IHCon () (UnQual () (Ident () "Ord")))
      (TyParen
         ()
         (TyApp
            ()
            (TyCon () (UnQual () (Ident () "Maybe")))
            (TyVar () (Ident () "a")))))

An optional explicit forall after instance is supported: instance forall a . Ord a => Ord (Maybe a) where becomes

IRule
   ()
   (Just [ UnkindedVar () (Ident () "a") ])
   ...

Constructors

IRule l (Maybe [TyVarBind l]) (Maybe (Context l)) (InstHead l) 
IParen l (InstRule l) 

data InstHead l Source

The instance head. The split between rule/head allow us to represent instance (Bounded a => Bounded [a]) where faithfully.

The structure of InstHead follows one of DeclHead.

For example, instance C (Maybe a) Int where is represented as

IHApp
   ()
   (IHApp
      ()
      (IHCon () (UnQual () (Ident () "C")))
      (TyParen
         ()
         (TyApp
            ()
            (TyCon () (UnQual () (Ident () "Maybe")))
            (TyVar () (Ident () "a")))))
   (TyCon () (UnQual () (Ident () "Int")))))

Constructors

IHCon l (QName l)

type or class name

IHInfix l (Type l) (QName l)

infix application of the type/class name to the left operand

IHParen l (InstHead l)

parenthesized instance head

IHApp l (InstHead l) (Type l)

application to one more type

data Binds l Source

A binding group inside a let or where clause.

Constructors

BDecls l [Decl l]

An ordinary binding group

IPBinds l [IPBind l]

A binding group for implicit parameters

data IPBind l Source

A binding of an implicit parameter.

Constructors

IPBind l (IPName l) (Exp l) 

data PatternSynDirection l Source

Constructors

Unidirectional

A unidirectional pattern synonym with "<-"

ImplicitBidirectional

A bidirectional pattern synonym with "="

ExplicitBidirectional l [Decl l]

A birectional pattern synonym with the construction specified.

Type classes and instances

data ClassDecl l Source

Declarations inside a class declaration.

Constructors

ClsDecl l (Decl l)

ordinary declaration

ClsDataFam l (Maybe (Context l)) (DeclHead l) (Maybe (Kind l))

declaration of an associated data type

ClsTyFam l (DeclHead l) (Maybe (Kind l))

declaration of an associated type synonym

ClsTyDef l (Type l) (Type l)

default choice for an associated type synonym

ClsDefSig l (Name l) (Type l)

default signature

data InstDecl l Source

Declarations inside an instance declaration.

Constructors

InsDecl l (Decl l)

ordinary declaration

InsType l (Type l) (Type l)

an associated type definition

InsData l (DataOrNew l) (Type l) [QualConDecl l] (Maybe (Deriving l))

an associated data type implementation

InsGData l (DataOrNew l) (Type l) (Maybe (Kind l)) [GadtDecl l] (Maybe (Deriving l))

an associated data type implemented using GADT style

data Deriving l Source

A deriving clause following a data type declaration.

Constructors

Deriving l [InstRule l] 

Data type declarations

data DataOrNew l Source

A flag stating whether a declaration is a data or newtype declaration.

Constructors

DataType l 
NewType l 

data ConDecl l Source

Declaration of an ordinary data constructor.

Constructors

ConDecl l (Name l) [Type l]

ordinary data constructor

InfixConDecl l (Type l) (Name l) (Type l)

infix data constructor

RecDecl l (Name l) [FieldDecl l]

record constructor

data QualConDecl l Source

A single constructor declaration within a data type declaration, which may have an existential quantification binding.

Constructors

QualConDecl l (Maybe [TyVarBind l]) (Maybe (Context l)) (ConDecl l) 

data GadtDecl l Source

A single constructor declaration in a GADT data type declaration.

If the GADT is declared using the record syntax, e.g.

data Ty where
  TCon :: { field1 :: Int, field2 :: Bool } -> Ty

then the fields are stored as a list of FieldDecls, and the final type (Ty in the above example) is stored in the last Type field.

If the GADT is declared using the ordinary syntax, e.g.

data Ty where
  TCon :: Int -> Bool -> Ty

then Maybe [FieldDecl l] is Nothing, and the whole constructor's type (such as Int -> Bool -> Ty) is stored in the last Type field.

Constructors

GadtDecl l (Name l) (Maybe [FieldDecl l]) (Type l) 

data BangType l Source

The type of a constructor argument or field, optionally including a strictness annotation.

Constructors

BangedTy l

strict component, marked with "!"

UnpackedTy l

unboxed component, marked with an UNPACK pragma

Function bindings

data Match l Source

Clauses of a function binding.

Constructors

Match l (Name l) [Pat l] (Rhs l) (Maybe (Binds l))

A clause defined with prefix notation, i.e. the function name followed by its argument patterns, the right-hand side and an optional where clause.

InfixMatch l (Pat l) (Name l) [Pat l] (Rhs l) (Maybe (Binds l))

A clause defined with infix notation, i.e. first its first argument pattern, then the function name, then its following argument(s), the right-hand side and an optional where clause. Note that there can be more than two arguments to a function declared infix, hence the list of pattern arguments.

data Rhs l Source

The right hand side of a function binding, pattern binding, or a case alternative.

Constructors

UnGuardedRhs l (Exp l)

unguarded right hand side (exp)

GuardedRhss l [GuardedRhs l]

guarded right hand side (gdrhs)

data GuardedRhs l Source

A guarded right hand side | stmts = exp, or | stmts -> exp for case alternatives. The guard is a series of statements when using pattern guards, otherwise it will be a single qualifier expression.

Constructors

GuardedRhs l [Stmt l] (Exp l) 

Class Assertions and Contexts

data Context l Source

A context is a set of assertions

Constructors

CxSingle l (Asst l) 
CxTuple l [Asst l] 
CxEmpty l 

data FunDep l Source

A functional dependency, given on the form l1 l2 ... ln -> r2 r3 .. rn

Constructors

FunDep l [Name l] [Name l] 

data Asst l Source

Class assertions. In Haskell 98, the argument would be a tyvar, but this definition allows multiple parameters, and allows them to be types. Also extended with support for implicit parameters and equality constraints.

Constructors

ClassA l (QName l) [Type l]

ordinary class assertion

AppA l (Name l) [Type l]

constraint kind assertion, Dict :: cxt a => Dict cxt

InfixA l (Type l) (QName l) (Type l)

class assertion where the class name is given infix

IParam l (IPName l) (Type l)

implicit parameter assertion

EqualP l (Type l) (Type l)

type equality constraint

ParenA l (Asst l)

parenthesised class assertion

WildCardA l (Maybe (Name l))

Context Wildcard

Types

data Type l Source

A type qualified with a context. An unqualified type has an empty context.

Constructors

TyForall l (Maybe [TyVarBind l]) (Maybe (Context l)) (Type l)

qualified type

TyFun l (Type l) (Type l)

function type

TyTuple l Boxed [Type l]

tuple type, possibly boxed

TyList l (Type l)

list syntax, e.g. [a], as opposed to [] a

TyParArray l (Type l)

parallel array syntax, e.g. [:a:]

TyApp l (Type l) (Type l)

application of a type constructor

TyVar l (Name l)

type variable

TyCon l (QName l)

named type or type constructor

TyParen l (Type l)

type surrounded by parentheses

TyInfix l (Type l) (QName l) (Type l)

infix type constructor

TyKind l (Type l) (Kind l)

type with explicit kind signature

TyPromoted l (Promoted l)

'K, a promoted data type (-XDataKinds).

TyEquals l (Type l) (Type l)

type equality predicate enabled by ConstraintKinds

TySplice l (Splice l)

template haskell splice type

TyBang l (BangType l) (Type l)

Strict type marked with "!" or type marked with UNPACK pragma.

TyWildCard l (Maybe (Name l))

Either an anonymous of named type wildcard

data Boxed Source

Flag denoting whether a tuple is boxed or unboxed.

Constructors

Boxed 
Unboxed 

data Kind l Source

An explicit kind annotation.

Constructors

KindStar l

*, the kind of types

KindFn l (Kind l) (Kind l)

->, the kind of a type constructor

KindParen l (Kind l)

a parenthesised kind

KindVar l (QName l)

k, a kind variable (-XPolyKinds)

KindApp l (Kind l) (Kind l)
k1 k2
KindTuple l [Kind l]

'(k1,k2,k3), a promoted tuple

KindList l (Kind l)

'[k1], a promoted list literal

data TyVarBind l Source

A type variable declaration, optionally with an explicit kind annotation.

Constructors

KindedVar l (Name l) (Kind l)

variable binding with kind annotation

UnkindedVar l (Name l)

ordinary variable binding

data Promoted l Source

Bools here are True if there was a leading quote which may be left out. For example '[k1,k2] means the same thing as [k1,k2].

Constructors

PromotedInteger l Integer String

parsed value and raw string

PromotedString l String String

parsed value and raw string

PromotedCon l Bool (QName l) 
PromotedList l Bool [Type l] 
PromotedTuple l [Type l] 
PromotedUnit l 

data TypeEqn l Source

A type equation as found in closed type families.

Constructors

TypeEqn l (Type l) (Type l) 

Expressions

data Exp l Source

Haskell expressions.

Constructors

Var l (QName l)

variable

IPVar l (IPName l)

implicit parameter variable

Con l (QName l)

data constructor

Lit l (Literal l)

literal constant

InfixApp l (Exp l) (QOp l) (Exp l)

infix application

App l (Exp l) (Exp l)

ordinary application

NegApp l (Exp l)

negation expression -exp (unary minus)

Lambda l [Pat l] (Exp l)

lambda expression

Let l (Binds l) (Exp l)

local declarations with let ... in ...

If l (Exp l) (Exp l) (Exp l)

if exp then exp else exp

MultiIf l [GuardedRhs l]

if | stmts -> exp ...

Case l (Exp l) [Alt l]

case exp of alts

Do l [Stmt l]

do-expression: the last statement in the list should be an expression.

MDo l [Stmt l]

mdo-expression

Tuple l Boxed [Exp l]

tuple expression

TupleSection l Boxed [Maybe (Exp l)]

tuple section expression, e.g. (,,3)

List l [Exp l]

list expression

ParArray l [Exp l]

parallel array expression

Paren l (Exp l)

parenthesised expression

LeftSection l (Exp l) (QOp l)

left section (exp qop)

RightSection l (QOp l) (Exp l)

right section (qop exp)

RecConstr l (QName l) [FieldUpdate l]

record construction expression

RecUpdate l (Exp l) [FieldUpdate l]

record update expression

EnumFrom l (Exp l)

unbounded arithmetic sequence, incrementing by 1: [from ..]

EnumFromTo l (Exp l) (Exp l)

bounded arithmetic sequence, incrementing by 1 [from .. to]

EnumFromThen l (Exp l) (Exp l)

unbounded arithmetic sequence, with first two elements given [from, then ..]

EnumFromThenTo l (Exp l) (Exp l) (Exp l)

bounded arithmetic sequence, with first two elements given [from, then .. to]

ParArrayFromTo l (Exp l) (Exp l)

Parallel array bounded arithmetic sequence, incrementing by 1 [:from .. to:]

ParArrayFromThenTo l (Exp l) (Exp l) (Exp l)

bounded arithmetic sequence, with first two elements given [:from, then .. to:]

ListComp l (Exp l) [QualStmt l]

ordinary list comprehension

ParComp l (Exp l) [[QualStmt l]]

parallel list comprehension

ParArrayComp l (Exp l) [[QualStmt l]]

parallel array comprehension

ExpTypeSig l (Exp l) (Type l)

expression with explicit type signature

VarQuote l (QName l)

'x for template haskell reifying of expressions

TypQuote l (QName l)

''T for template haskell reifying of types

BracketExp l (Bracket l)

template haskell bracket expression

SpliceExp l (Splice l)

template haskell splice expression

QuasiQuote l String String

quasi-quotaion: [$name| string |]

XTag l (XName l) [XAttr l] (Maybe (Exp l)) [Exp l]

xml element, with attributes and children

XETag l (XName l) [XAttr l] (Maybe (Exp l))

empty xml element, with attributes

XPcdata l String

PCDATA child element

XExpTag l (Exp l)

escaped haskell expression inside xml

XChildTag l [Exp l]

children of an xml element

CorePragma l String (Exp l)

CORE pragma

SCCPragma l String (Exp l)

SCC pragma

GenPragma l String (Int, Int) (Int, Int) (Exp l)

GENERATED pragma

Proc l (Pat l) (Exp l)

arrows proc: proc pat -> exp

LeftArrApp l (Exp l) (Exp l)

arrow application (from left): exp -< exp

RightArrApp l (Exp l) (Exp l)

arrow application (from right): exp >- exp

LeftArrHighApp l (Exp l) (Exp l)

higher-order arrow application (from left): exp -<< exp

RightArrHighApp l (Exp l) (Exp l)

higher-order arrow application (from right): exp >>- exp

LCase l [Alt l]

case alts

ExprHole l

Expression hole

data Stmt l Source

A statement, representing both a stmt in a do-expression, an ordinary qual in a list comprehension, as well as a stmt in a pattern guard.

Constructors

Generator l (Pat l) (Exp l)

a generator: pat <- exp

Qualifier l (Exp l)

an exp by itself: in a do-expression, an action whose result is discarded; in a list comprehension and pattern guard, a guard expression

LetStmt l (Binds l)

local bindings

RecStmt l [Stmt l]

a recursive binding group for arrows

data QualStmt l Source

A general transqual in a list comprehension, which could potentially be a transform of the kind enabled by TransformListComp.

Constructors

QualStmt l (Stmt l)

an ordinary statement

ThenTrans l (Exp l)

then exp

ThenBy l (Exp l) (Exp l)

then exp by exp

GroupBy l (Exp l)

then group by exp

GroupUsing l (Exp l)

then group using exp

GroupByUsing l (Exp l) (Exp l)

then group by exp using exp

data FieldUpdate l Source

An fbind in a labeled construction or update expression.

Constructors

FieldUpdate l (QName l) (Exp l)

ordinary label-expresion pair

FieldPun l (QName l)

record field pun

FieldWildcard l

record field wildcard

data Alt l Source

An alt alternative in a case expression.

Constructors

Alt l (Pat l) (Rhs l) (Maybe (Binds l)) 

data XAttr l Source

An xml attribute, which is a name-expression pair.

Constructors

XAttr l (XName l) (Exp l) 

Patterns

data Pat l Source

A pattern, to be matched against a value.

Constructors

PVar l (Name l)

variable

PLit l (Sign l) (Literal l)

literal constant

PNPlusK l (Name l) Integer

n+k pattern

PInfixApp l (Pat l) (QName l) (Pat l)

pattern with an infix data constructor

PApp l (QName l) [Pat l]

data constructor and argument patterns

PTuple l Boxed [Pat l]

tuple pattern

PList l [Pat l]

list pattern

PParen l (Pat l)

parenthesized pattern

PRec l (QName l) [PatField l]

labelled pattern, record style

PAsPat l (Name l) (Pat l)

@-pattern

PWildCard l

wildcard pattern: _

PIrrPat l (Pat l)

irrefutable pattern: ~pat

PatTypeSig l (Pat l) (Type l)

pattern with type signature

PViewPat l (Exp l) (Pat l)

view patterns of the form (exp -> pat)

PRPat l [RPat l]

regular list pattern

PXTag l (XName l) [PXAttr l] (Maybe (Pat l)) [Pat l]

XML element pattern

PXETag l (XName l) [PXAttr l] (Maybe (Pat l))

XML singleton element pattern

PXPcdata l String

XML PCDATA pattern

PXPatTag l (Pat l)

XML embedded pattern

PXRPats l [RPat l]

XML regular list pattern

PQuasiQuote l String String

quasi quote pattern: [$name| string |]

PBangPat l (Pat l)

strict (bang) pattern: f !x = ...

data PatField l Source

An fpat in a labeled record pattern.

Constructors

PFieldPat l (QName l) (Pat l)

ordinary label-pattern pair

PFieldPun l (QName l)

record field pun

PFieldWildcard l

record field wildcard

data PXAttr l Source

An XML attribute in a pattern.

Constructors

PXAttr l (XName l) (Pat l) 

data RPat l Source

An entity in a regular pattern.

Constructors

RPOp l (RPat l) (RPatOp l)

operator pattern, e.g. pat*

RPEither l (RPat l) (RPat l)

choice pattern, e.g. (1 | 2)

RPSeq l [RPat l]

sequence pattern, e.g. (| 1, 2, 3 |)

RPGuard l (Pat l) [Stmt l]

guarded pattern, e.g. (| p | p < 3 |)

RPCAs l (Name l) (RPat l)

non-linear variable binding, e.g. (foo@:(1 | 2))*

RPAs l (Name l) (RPat l)

linear variable binding, e.g. foo@(1 | 2)

RPParen l (RPat l)

parenthesised pattern, e.g. (2*)

RPPat l (Pat l)

an ordinary pattern

data RPatOp l Source

A regular pattern operator.

Constructors

RPStar l

* = 0 or more

RPStarG l

*! = 0 or more, greedy

RPPlus l

+ = 1 or more

RPPlusG l

+! = 1 or more, greedy

RPOpt l

? = 0 or 1

RPOptG l

?! = 0 or 1, greedy

Literals

data Literal l Source

literal Values of this type hold the abstract value of the literal, along with the precise string representation used. For example, 10, 0o12 and 0xa have the same value representation, but each carry a different string representation.

Constructors

Char l Char String

character literal

String l String String

string literal

Int l Integer String

integer literal

Frac l Rational String

floating point literal

PrimInt l Integer String

unboxed integer literal

PrimWord l Integer String

unboxed word literal

PrimFloat l Rational String

unboxed float literal

PrimDouble l Rational String

unboxed double literal

PrimChar l Char String

unboxed character literal

PrimString l String String

unboxed string literal

data Sign l Source

An indication whether a literal pattern has been negated or not.

Constructors

Signless l 
Negative l 

Variables, Constructors and Operators

data QName l Source

This type is used to represent qualified variables, and also qualified constructors.

Constructors

Qual l (ModuleName l) (Name l)

name qualified with a module name

UnQual l (Name l)

unqualified local name

Special l (SpecialCon l)

built-in constructor with special syntax

data Name l Source

This type is used to represent variables, and also constructors.

Constructors

Ident l String

varid or conid.

Symbol l String

varsym or consym

data QOp l Source

Possibly qualified infix operators (qop), appearing in expressions.

Constructors

QVarOp l (QName l)

variable operator (qvarop)

QConOp l (QName l)

constructor operator (qconop)

data Op l Source

Operators appearing in infix declarations are never qualified.

Constructors

VarOp l (Name l)

variable operator (varop)

ConOp l (Name l)

constructor operator (conop)

data SpecialCon l Source

Constructors with special syntax. These names are never qualified, and always refer to builtin type or data constructors.

Constructors

UnitCon l

unit type and data constructor ()

ListCon l

list type constructor []

FunCon l

function type constructor ->

TupleCon l Boxed Int

n-ary tuple type and data constructors (,) etc, possibly boxed (#,#)

Cons l

list data constructor (:)

UnboxedSingleCon l

unboxed singleton tuple constructor (# #)

data CName l Source

A name (cname) of a component of a class or data type in an import or export specification.

Constructors

VarName l (Name l)

name of a method or field

ConName l (Name l)

name of a data constructor

data IPName l Source

An implicit parameter name.

Constructors

IPDup l String

?ident, non-linear implicit parameter

IPLin l String

%ident, linear implicit parameter

data XName l Source

The name of an xml element or attribute, possibly qualified with a namespace.

Constructors

XName l String 
XDomName l String String 

Template Haskell

data Bracket l Source

A template haskell bracket expression.

Constructors

ExpBracket l (Exp l)

expression bracket: [| ... |]

PatBracket l (Pat l)

pattern bracket: [p| ... |]

TypeBracket l (Type l)

type bracket: [t| ... |]

DeclBracket l [Decl l]

declaration bracket: [d| ... |]

data Splice l Source

A template haskell splice expression

Constructors

IdSplice l String

variable splice: $var

ParenSplice l (Exp l)

parenthesised expression splice: $(exp)

FFI

data Safety l Source

The safety of a foreign function call.

Constructors

PlayRisky l

unsafe

PlaySafe l Bool

safe (False) or threadsafe (True)

PlayInterruptible l

interruptible

data CallConv l Source

The calling convention of a foreign function call.

Constructors

StdCall l 
CCall l 
CPlusPlus l 
DotNet l 
Jvm l 
Js l 
JavaScript l 
CApi l 

Pragmas

data ModulePragma l Source

A top level options pragma, preceding the module header.

Constructors

LanguagePragma l [Name l]

LANGUAGE pragma

OptionsPragma l (Maybe Tool) String

OPTIONS pragma, possibly qualified with a tool, e.g. OPTIONS_GHC

AnnModulePragma l (Annotation l)

ANN pragma with module scope

data Tool Source

Recognised tools for OPTIONS pragmas.

data Overlap l Source

Recognised overlaps for overlap pragmas.

Constructors

NoOverlap l

NO_OVERLAP pragma

Overlap l

OVERLAP pragma

Incoherent l

INCOHERENT pragma

data Rule l Source

The body of a RULES pragma.

Constructors

Rule l String (Maybe (Activation l)) (Maybe [RuleVar l]) (Exp l) (Exp l) 

data RuleVar l Source

Variables used in a RULES pragma, optionally annotated with types

Constructors

RuleVar l (Name l) 
TypedRuleVar l (Name l) (Type l) 

data Annotation l Source

An annotation through an ANN pragma.

Constructors

Ann l (Name l) (Exp l)

An annotation for a declared name.

TypeAnn l (Name l) (Exp l)

An annotation for a declared type.

ModuleAnn l (Exp l)

An annotation for the defining module.

data BooleanFormula l Source

A boolean formula for MINIMAL pragmas.

Constructors

VarFormula l (Name l)

A variable.

AndFormula l [BooleanFormula l]

And boolean formulas.

OrFormula l [BooleanFormula l]

Or boolean formulas.

ParenFormula l (BooleanFormula l)

Parenthesized boolean formulas.

Builtin names

Modules

Main function of a program

Constructors

unit_con :: l -> Exp l Source

tuple_con :: l -> Boxed -> Int -> Exp l Source

Special identifiers

as_name :: l -> Name l Source

dot_name :: l -> Name l Source

jvm_name :: l -> Name l Source

js_name :: l -> Name l Source

Type constructors

tuple_tycon :: l -> Boxed -> Int -> Type l Source

Source coordinates

Annotated trees

class Functor ast => Annotated ast where Source

AST nodes are annotated, and this class allows manipulation of the annotations.

Methods

ann :: ast l -> l Source

Retrieve the annotation of an AST node.

amap :: (l -> l) -> ast l -> ast l Source

Change the annotation of an AST node. Note that only the annotation of the node itself is affected, and not the annotations of any child nodes. if all nodes in the AST tree are to be affected, use fmap.

Instances

Annotated Alt Source 
Annotated FieldUpdate Source 
Annotated QualStmt Source 
Annotated Stmt Source 
Annotated PatField Source 
Annotated RPat Source 
Annotated RPatOp Source 
Annotated PXAttr Source 
Annotated Pat Source 
Annotated WarningText Source 
Annotated RuleVar Source 
Annotated Rule Source 
Annotated Activation Source 
Annotated Overlap Source 
Annotated ModulePragma Source 
Annotated CallConv Source 
Annotated Safety Source 
Annotated Splice Source 
Annotated Bracket Source 
Annotated XAttr Source 
Annotated XName Source 
Annotated Exp Source 
Annotated Sign Source 
Annotated Literal Source 
Annotated Asst Source 
Annotated Context Source 
Annotated FunDep Source 
Annotated Kind Source 
Annotated TyVarBind Source 
Annotated Promoted Source 
Annotated Type Source 
Annotated GuardedRhs Source 
Annotated Rhs Source 
Annotated BangType Source 
Annotated InstDecl Source 
Annotated ClassDecl Source 
Annotated GadtDecl Source 
Annotated FieldDecl Source 
Annotated ConDecl Source 
Annotated QualConDecl Source 
Annotated Match Source 
Annotated IPBind Source 
Annotated Binds Source 
Annotated Deriving Source 
Annotated InstHead Source 
Annotated InstRule Source 
Annotated DeclHead Source 
Annotated DataOrNew Source 
Annotated Role Source 
Annotated BooleanFormula Source 
Annotated Annotation Source 
Annotated TypeEqn Source 
Annotated Decl Source 
Annotated Assoc Source 
Annotated ImportSpec Source 
Annotated ImportSpecList Source 
Annotated ImportDecl Source 
Annotated Namespace Source 
Annotated ExportSpec Source 
Annotated ExportSpecList Source 
Annotated ModuleHead Source 
Annotated Module Source 
Annotated CName Source 
Annotated Op Source 
Annotated QOp Source 
Annotated IPName Source 
Annotated Name Source 
Annotated QName Source 
Annotated SpecialCon Source 
Annotated ModuleName Source 

(=~=) :: (Annotated a, Eq (a ())) => a l1 -> a l2 -> Bool Source

Test if two AST elements are equal modulo annotations.