!

Whenever a data constructor is applied, each argument to the
constructor is evaluated if and only if the corresponding type in the
algebraic datatype declaration has a strictness flag, denoted by an
exclamation point. For example:

dataSTLista=STConsa!(STLista)-- the second argument to STCons will be -- evaluated before STCons is applied|STNil

to illustrate the difference between strict versus lazy constructor
application, consider the following:

stList=STCons1undefinedlzList=(:)1undefinedstHead(STConsh_)=h-- this evaluates to undefined when applied to stListlzHead(h:_)=h-- this evaluates to 1 when applied to lzList

! is also used in the "bang patterns" (GHC extension), to indicate
strictness in patterns:

f!x!y=x+y

'

Character literal: 'a'

Template Haskell: Name of a (value) variable or data constructor: 'length, 'Left

[|, |]

\

The backslash "\" is used

in multiline strings

"foo\ \bar"

in lambda functions

\x->x+1

_

Patterns of the form _ are wildcards and are useful when some part of a
pattern is not referenced on the right-hand-side. It is as if an
identifier not used elsewhere were put in its place. For example,

caseeof{[x,_,_]->ifx==0thenTrueelseFalse}

is equivalent to:

caseeof{[x,y,z]->ifx==0thenTrueelseFalse}

`

A function enclosed in back ticks "`" can be used as an infix operator.

Equality constraints. Assert that two types in a context must be the same:

example::Fa~b=>a->b

Here the type "F a" must be the same as the type "b", which allows one to constrain polymorphism (especially where type families are involved), but to a lesser extent than functional dependencies. See Type Families.

as

Renaming module imports. Like qualified and hiding, as is not a reserved word but may be used as function or variable name.

importqualifiedData.MapasMmain=print(M.empty::M.MapInt())

case, of

A case expression has the general form

caseeof{p1match1;...;pnmatchn}

where each matchi is of the general form

|g1->e1...|gm->emwheredecls

Each alternative consists of patterns pi and their matches, matchi. Each
matchi in turn consists of a sequence of pairs of guards gij and bodies eij
(expressions), followed by optional bindings (declsi) that scope over all
of the guards and expressions of the alternative. An alternative of the
form

pat->expwheredecls

is treated as shorthand for:

pat|True->expwheredecls

A case expression must have at least one alternative and each
alternative must have at least one body. Each body must have the same
type, and the type of the whole expression is that type.

A case expression is evaluated by pattern matching the expression e
against the individual alternatives. The alternatives are tried
sequentially, from top to bottom. If e matches the pattern in the
alternative, the guards for that alternative are tried sequentially from
top to bottom, in the environment of the case expression extended first
by the bindings created during the matching of the pattern, and then by
the declsi in the where clause associated with that alternative. If one
of the guards evaluates to True, the corresponding right-hand side is
evaluated in the same environment as the guard. If all the guards
evaluate to False, matching continues with the next alternative. If no
match succeeds, the result is _|_.

class

A class declaration
introduces a new type class and the overloaded operations that must be
supported by any type that is an instance of that class.

classNumawhere(+)::a->a->anegate::a->a

data

The data
declaration is how one introduces new algebraic data types into
Haskell. For example:

dataSeta=NilSet|ConsSeta(Seta)

Another example, to create a datatype to hold an abstract syntax tree for an expression, one could use:

data family

data instance

default

Ambiguities in the class Num are most common, so Haskell provides
a way to resolve them---with a default declaration:

default(Int)

Only one default declaration is permitted per module, and its effect is
limited to that module. If no default declaration is given in a module
then it assumed to be:

default(Integer,Double)

deriving

data and newtype declarations contain an optional deriving form. If the
form is included, then derived instance declarations are automatically
generated for the datatype in each of the named classes.

Derived instances provide convenient commonly-used operations for user-defined
datatypes. For example, derived instances for datatypes in the class Eq
define the operations == and /=, freeing the programmer from the need to
define them.

do

forall

This is a GHC/Hugs extension, and as such is not portable Haskell 98/2010.
It is only a reserved word within types.

Type variables in a Haskell type expression are all assumed to be
universally quantified; there is no explicit syntax for universal
quantification, in standard Haskell 98/2010. For example, the type expression
a->a denotes the type foralla.a->a.
For clarity, however, we often write quantification explicitly when
discussing the types of Haskell programs. When we write an explicitly
quantified type, the scope of the forall extends as far to the right as
possible; for example,

foreign

A keyword for the Foreign Function Interface (commonly called the FFI) that introduces either a foreignimport declaration, which makes a function from a non-Haskell library available in a Haskell program, or a foreignexport declaration, which allows a function from a Haskell module to be called in non-Haskell contexts.

hiding

When importing modules, without introducing a name into scope, entities can be excluded by using the form

hiding(import1,...,importn)

which specifies that all entities exported by the named module should be
imported except for those named in the list.

For example:

importPreludehiding(lookup,filter,foldr,foldl,null,map)

if, then, else

A conditional expression has the form:

ife1thene2elsee3

and returns the value of e2 if the value of e1 is True, e3 if e1 is False, and _|_ otherwise.

maxab=ifa>bthenaelseb

import

Modules may reference
other modules via explicit import declarations, each giving the name of
a module to be imported and specifying its entities to be imported.

infix, infixl, infixr

A fixity declaration gives
the fixity and binding precedence of one or more operators. The integer
in a fixity declaration must be in the range 0 to 9. A fixity
declaration may appear anywhere that a type signature appears and, like
a type signature, declares a property of a particular operator.

instance

An instance declaration declares that a type is an instance of a class
and includes the definitions of the overloaded operations - called class
methods - instantiated on the named type.

instanceNumIntwherex+y=addIntxynegatex=negateIntx

let, in

Let expressions have the general form:

let{d1;...;dn}ine

They introduce a nested, lexically-scoped, mutually-recursive list of declarations (let is often called letrec in other languages). The scope of the declarations is the expression e and the right hand side of the declarations.

Within do-blocks or list comprehensions let{d1;...;dn} without in serves to indroduce local bindings.

newtype

The newtype declaration is how one introduces a renaming for an algebraic data type into Haskell. This is different from type below, as a newtype requires a new constructor as well. As an example, when writing a compiler
one sometimes further qualifies Identifiers to assist in type safety checks: