<s>
The	B-Application
Glasgow	I-Application
Haskell	I-Application
Compiler	I-Application
(	O
GHC	O
)	O
is	O
an	O
open-source	B-Application
native	B-Language
code	I-Language
compiler	B-Language
for	O
the	O
functional	B-Language
programming	I-Language
language	I-Language
Haskell	B-Language
.	O
</s>
<s>
It	O
provides	O
a	O
cross-platform	O
environment	O
for	O
the	O
writing	O
and	O
testing	O
of	O
Haskell	B-Language
code	O
and	O
it	O
supports	O
numerous	O
extensions	O
,	O
libraries	O
,	O
and	O
optimisations	O
that	O
streamline	O
the	O
process	O
of	O
generating	O
and	O
executing	O
code	O
.	O
</s>
<s>
GHC	O
is	O
the	O
most	O
commonly	O
used	O
Haskell	B-Language
compiler	B-Language
.	O
</s>
<s>
GHC	O
originally	O
started	O
in	O
1989	O
as	O
a	O
prototype	O
,	O
written	O
in	O
LML	O
(	O
Lazy	B-Language
ML	I-Language
)	O
by	O
Kevin	O
Hammond	O
at	O
the	O
University	O
of	O
Glasgow	O
.	O
</s>
<s>
Later	O
that	O
year	O
,	O
the	O
prototype	O
was	O
completely	O
rewritten	O
in	O
Haskell	B-Language
,	O
except	O
for	O
its	O
parser	B-Language
,	O
by	O
Cordelia	O
Hall	O
,	O
Will	O
Partain	O
,	O
and	O
Simon	O
Peyton	O
Jones	O
.	O
</s>
<s>
Its	O
first	O
beta	O
release	O
was	O
on	O
1	O
April	O
1991	O
and	O
subsequent	O
releases	O
added	O
a	O
strictness	B-Application
analyzer	I-Application
as	O
well	O
as	O
language	O
extensions	O
such	O
as	O
monadic	O
I/O	O
,	O
mutable	O
arrays	O
,	O
unboxed	O
data	O
types	O
,	O
concurrent	O
and	O
parallel	O
programming	O
models	O
(	O
such	O
as	O
software	B-Operating_System
transactional	I-Operating_System
memory	I-Operating_System
and	O
data	B-Operating_System
parallelism	I-Operating_System
)	O
and	O
a	O
profiler	O
.	O
</s>
<s>
Since	O
2009	O
,	O
third-party	O
contributions	O
to	O
GHC	O
have	O
been	O
funded	O
by	O
the	O
Industrial	O
Haskell	B-Language
Group	O
.	O
</s>
<s>
Since	O
early	O
releases	O
the	O
official	O
website	O
has	O
referred	O
to	O
GHC	O
as	O
The	B-Application
Glasgow	I-Application
Haskell	I-Application
Compiler	I-Application
,	O
whereas	O
in	O
the	O
executable	O
version	O
command	O
it	O
is	O
identified	O
as	O
The	O
Glorious	O
Glasgow	O
Haskell	B-Language
Compilation	B-Language
System	O
.	O
</s>
<s>
Initially	O
,	O
it	O
had	O
the	O
internal	O
name	O
of	O
The	O
Glamorous	O
Glasgow	B-Application
Haskell	I-Application
Compiler	I-Application
.	O
</s>
<s>
GHC	O
itself	O
is	O
written	B-Application
in	I-Application
Haskell	I-Application
,	O
but	O
the	O
runtime	B-Device
system	I-Device
for	O
Haskell	B-Language
,	O
essential	O
to	O
run	O
programs	O
,	O
is	O
written	O
in	O
C	B-Language
and	O
C--	B-Language
.	O
</s>
<s>
GHC	O
's	O
front	O
end	O
—	O
incorporating	O
the	O
lexer	B-Application
,	O
parser	B-Language
and	O
typechecker	O
—	O
is	O
designed	O
to	O
preserve	O
as	O
much	O
information	O
about	O
the	O
source	O
language	O
as	O
possible	O
until	O
after	O
type	O
inference	O
is	O
complete	O
,	O
toward	O
the	O
goal	O
of	O
providing	O
clear	O
error	O
messages	O
to	O
users	O
.	O
</s>
<s>
After	O
type	O
checking	O
,	O
the	O
Haskell	B-Language
code	O
is	O
desugared	O
into	O
a	O
typed	O
intermediate	O
language	O
known	O
as	O
"	O
Core	O
"	O
(	O
based	O
on	O
System	O
F	O
,	O
extended	O
with	O
let	O
and	O
case	O
expressions	O
)	O
.	O
</s>
<s>
Core	O
has	O
been	O
extended	O
to	O
support	O
generalized	B-Application
algebraic	I-Application
datatypes	I-Application
in	O
its	O
type	O
system	O
,	O
and	O
is	O
now	O
based	O
on	O
an	O
extension	O
to	O
System	O
F	O
known	O
as	O
System	O
FC	O
.	O
</s>
<s>
In	O
the	O
tradition	O
of	O
type-directed	O
compilation	B-Language
,	O
GHC	O
's	O
simplifier	O
,	O
or	O
"	O
middle	O
end	O
"	O
,	O
where	O
most	O
of	O
the	O
optimizations	B-Application
implemented	O
in	O
GHC	O
are	O
performed	O
,	O
is	O
structured	O
as	O
a	O
series	O
of	O
source-to-source	O
transformations	B-Application
on	O
Core	O
code	O
.	O
</s>
<s>
The	O
analyses	O
and	O
transformations	B-Application
performed	O
in	O
this	O
compiler	B-Language
stage	O
include	O
demand	O
analysis	O
(	O
a	O
generalization	O
of	O
strictness	B-Application
analysis	I-Application
)	O
,	O
application	O
of	O
user-defined	O
rewrite	O
rules	O
(	O
including	O
a	O
set	O
of	O
rules	O
included	O
in	O
GHC	O
's	O
standard	O
libraries	O
that	O
performs	O
foldr/build	O
fusion	B-Application
)	O
,	O
unfolding	O
(	O
called	O
"	O
inlining	O
"	O
in	O
more	O
traditional	O
compilers	B-Language
)	O
,	O
let-floating	O
,	O
an	O
analysis	O
that	O
determines	O
which	O
function	O
arguments	O
can	O
be	O
unboxed	O
,	O
constructed	B-Application
product	I-Application
result	I-Application
analysis	I-Application
,	O
specialization	O
of	O
overloaded	O
functions	O
,	O
as	O
well	O
as	O
a	O
set	O
of	O
simpler	O
local	O
transformations	B-Application
such	O
as	O
constant	O
folding	O
and	O
beta	O
reduction	O
.	O
</s>
<s>
The	O
back	O
end	O
of	O
the	O
compiler	B-Language
transforms	O
Core	O
code	O
into	O
an	O
internal	O
representation	O
of	O
C--	B-Language
,	O
via	O
an	O
intermediate	O
language	O
STG	O
(	O
short	O
for	O
"	O
Spineless	O
Tagless	O
G-machine	O
"	O
)	O
.	O
</s>
<s>
The	O
C--	B-Language
code	O
can	O
then	O
take	O
one	O
of	O
three	O
routes	O
:	O
it	O
is	O
either	O
printed	O
as	O
C	B-Language
code	O
for	O
compilation	B-Language
with	O
GCC	B-Application
,	O
converted	O
directly	O
into	O
native	O
machine	B-Language
code	I-Language
(	O
the	O
traditional	O
"	O
code	B-Application
generation	I-Application
"	O
phase	O
)	O
,	O
or	O
converted	O
to	O
LLVM	O
IR	O
for	O
compilation	B-Language
with	O
LLVM	O
.	O
</s>
<s>
In	O
all	O
three	O
cases	O
,	O
the	O
resultant	O
native	B-Language
code	I-Language
is	O
finally	O
linked	O
against	O
the	O
GHC	O
runtime	B-Device
system	I-Device
to	O
produce	O
an	O
executable	O
.	O
</s>
<s>
GHC	O
complies	O
with	O
the	O
language	O
standards	O
,	O
both	O
Haskell	B-Language
98	I-Language
and	O
Haskell	B-Language
2010	O
.	O
</s>
<s>
It	O
also	O
supports	O
many	O
optional	O
extensions	O
to	O
the	O
Haskell	B-Language
standard	O
:	O
for	O
example	O
,	O
the	O
software	B-Operating_System
transactional	I-Operating_System
memory	I-Operating_System
(	O
STM	O
)	O
library	O
,	O
which	O
allows	O
for	O
Composable	B-Operating_System
Memory	I-Operating_System
Transactions	I-Operating_System
.	O
</s>
<s>
A	O
number	O
of	O
extensions	O
to	O
Haskell	B-Language
have	O
been	O
proposed	O
.	O
</s>
<s>
As	O
such	O
,	O
each	O
extension	O
may	O
not	O
be	O
supported	O
by	O
all	O
Haskell	B-Language
implementations	O
.	O
</s>
<s>
The	O
extensions	O
supported	O
by	O
the	B-Application
Glasgow	I-Application
Haskell	I-Application
Compiler	I-Application
include	O
:	O
</s>
<s>
These	O
represent	O
the	O
primitive	O
datatypes	O
of	O
the	O
underlying	O
hardware	O
,	O
without	O
the	O
indirection	O
of	O
a	O
pointer	O
to	O
the	O
heap	B-Application
or	O
the	O
possibility	O
of	O
deferred	O
evaluation	O
.	O
</s>
<s>
More	O
convenient	O
syntax	O
for	O
working	O
with	O
modules	O
,	O
patterns	O
,	O
list	B-Language
comprehensions	I-Language
,	O
operators	O
,	O
records	O
,	O
and	O
tuples	O
.	O
</s>
<s>
Syntactic	O
sugar	O
for	O
computing	O
with	O
arrows	B-Application
and	O
recursively-defined	O
monadic	O
values	O
.	O
</s>
<s>
Both	O
of	O
these	O
concepts	O
extend	O
the	O
monadic	O
-notation	O
provided	O
in	O
standard	O
Haskell	B-Language
.	O
</s>
<s>
Template	B-Application
Haskell	I-Application
,	O
a	O
system	O
for	O
compile-time	O
metaprogramming	B-Application
.	O
</s>
<s>
A	O
programmer	O
can	O
write	O
expressions	O
that	O
produce	O
Haskell	B-Language
code	O
in	O
the	O
form	O
of	O
an	O
abstract	B-Data_Structure
syntax	I-Data_Structure
tree	I-Data_Structure
.	O
</s>
<s>
These	O
expressions	O
are	O
typechecked	O
and	O
evaluated	O
at	O
compile	B-Language
time	O
;	O
the	O
generated	O
code	O
is	O
then	O
included	O
as	O
if	O
it	O
were	O
written	O
directly	O
by	O
the	O
programmer	O
.	O
</s>
<s>
Together	O
with	O
the	O
ability	O
to	O
reflect	B-Language
on	O
definitions	O
,	O
this	O
provides	O
a	O
powerful	O
tool	O
for	O
further	O
extensions	O
to	O
the	O
language	O
.	O
</s>
<s>
Quasi-quotation	O
is	O
useful	O
when	O
a	O
metaprogram	O
written	B-Application
in	I-Application
Haskell	I-Application
manipulates	O
code	O
written	O
in	O
a	O
language	O
other	O
than	O
Haskell	B-Language
.	O
</s>
<s>
Generic	B-Language
typeclasses	O
,	O
which	O
specify	O
functions	O
solely	O
in	O
terms	O
of	O
the	O
algebraic	O
structure	O
of	O
the	O
types	O
they	O
operate	O
on	O
.	O
</s>
<s>
Compiler	B-Language
pragmas	O
for	O
directing	O
optimizations	B-Application
such	O
as	O
inline	O
expansion	O
and	O
specializing	O
functions	O
for	O
particular	O
types	O
.	O
</s>
<s>
An	O
expressive	O
static	O
type	O
system	O
is	O
one	O
of	O
the	O
major	O
defining	O
features	O
of	O
Haskell	B-Language
.	O
</s>
<s>
The	B-Application
Glasgow	I-Application
Haskell	I-Application
Compiler	I-Application
supports	O
an	O
extended	O
type	O
system	O
based	O
on	O
the	O
theoretical	O
System	O
FC	O
.	O
</s>
<s>
Arbitrary-rank	O
and	O
impredicative	O
polymorphism	B-Application
.	O
</s>
<s>
Essentially	O
,	O
a	O
polymorphic	B-Application
function	I-Application
or	O
datatype	O
constructor	O
may	O
require	O
that	O
one	O
of	O
its	O
arguments	O
is	O
itself	O
polymorphic	B-Application
.	O
</s>
<s>
Generalized	B-Application
algebraic	I-Application
data	I-Application
types	I-Application
.	O
</s>
<s>
Each	O
constructor	O
of	O
a	O
polymorphic	B-Application
datatype	O
can	O
encode	O
information	O
into	O
the	O
resulting	O
type	O
.	O
</s>
<s>
Such	O
a	O
value	O
is	O
very	O
similar	O
to	O
an	O
object	O
as	O
found	O
in	O
object-oriented	B-Language
programming	I-Language
languages	I-Language
.	O
</s>
<s>
These	O
can	O
be	O
useful	O
to	O
represent	O
data	O
in	O
type-level	O
metaprogramming	B-Application
.	O
</s>
<s>
Whereas	O
parametric	O
polymorphism	B-Application
provides	O
the	O
same	O
structure	O
for	O
every	O
type	O
instantiation	O
,	O
type	O
families	O
provide	O
ad	O
hoc	O
polymorphism	B-Application
with	O
implementations	O
that	O
can	O
differ	O
between	O
instantiations	O
.	O
</s>
<s>
Use	O
cases	O
include	O
content-aware	O
optimizing	O
containers	O
and	O
type-level	O
metaprogramming	B-Application
.	O
</s>
<s>
Implicit	O
function	O
parameters	O
that	O
have	O
dynamic	O
scope	B-Language
.	O
</s>
<s>
Thus	O
a	O
type	O
class	O
can	O
describe	O
not	O
only	O
a	O
set	O
of	O
types	O
,	O
but	O
an	O
n-ary	B-Algorithm
relation	I-Algorithm
on	O
types	O
.	O
</s>
<s>
Functional	B-Application
dependencies	I-Application
,	O
which	O
constrain	O
parts	O
of	O
that	O
relation	B-Algorithm
to	O
be	O
a	O
mathematical	O
function	O
on	O
types	O
.	O
</s>
<s>
When	O
these	O
are	O
enabled	O
in	O
full	O
,	O
the	O
type	O
class	O
system	O
becomes	O
a	O
Turing-complete	O
language	O
for	O
logic	B-Language
programming	I-Language
at	O
compile	B-Language
time	O
.	O
</s>
<s>
New	O
type	O
classes	O
for	O
generic	B-Language
programming	I-Language
and	O
common	O
recursion	O
patterns	O
are	O
supported	O
.	O
</s>
<s>
Versions	O
of	O
GHC	O
are	O
available	O
for	O
several	O
platforms	B-Device
,	O
including	O
Windows	B-Application
and	O
most	O
varieties	O
of	O
Unix	B-Application
(	O
such	O
as	O
Linux	B-Application
,	O
FreeBSD	B-Operating_System
,	O
OpenBSD	B-Operating_System
,	O
and	O
macOS	B-Application
)	O
.	O
</s>
<s>
GHC	O
has	O
also	O
been	O
ported	O
to	O
several	O
different	O
processor	B-General_Concept
architectures	I-General_Concept
.	O
</s>
