All Topics  
Glasgow Haskell Compiler

 

   Email Print
   Bookmark   Link






 

Glasgow Haskell Compiler



 
 
The Glorious Glasgow Haskell Compilation System, more commonly known as the Glasgow Haskell Compiler or GHC, is an open source
Open source

Open source is an approach to design, development, and distribution offering practical accessibility to a product's source . Some consider open source as one of various possible design approaches, while others consider it a critical Strategy element of their business operations....
 native code compiler
Compiler

A compiler is a computer program that transforms source code written in a programming language into another computer language . The most common reason for wanting to transform source code is to create an executable program....
 for the functional
Functional programming

In computer science, functional programming is a programming paradigm that treats computation as the evaluation of function s and avoids program state and immutable object data....
 programming
Computer programming

Computer programming is the process of writing, testing, debugging/troubleshooting, and maintaining the source code of computer programs. This source code is written in a programming language....
 language
Programming language

A programming language is a machine-readable artificial language designed to express computations that can be performed by a machine, particularly a computer....
 Haskell
Haskell (programming language)

Haskell is a standardized, purely functional programming language with non-strict programming language, named after logician Haskell Curry. The goals of the language are described as:...
. The lead developers are Simon Peyton Jones
Simon Peyton Jones

Simon Peyton Jones is a British computer scientist who researches the implementation and application software of functional programming languages, particularly lazy evaluation....
 and Simon Marlow.

originally started in 1989 as a prototype, written in LML (Lazy ML)
Lazy ML

Lazy ML is a functional programming language developed in the early 1980s by Lennart Augustsson and Thomas Johnsson at Chalmers University of Technology, prior to Miranda programming language and Haskell ....
 by Kevin Hammond at the University of Glasgow
University of Glasgow

The University of Glasgow was founded in 1451, in Glasgow, Scotland, and, along with its contemporary institution, the University of St Andrews, it formed the Kingdom of Scotland's equivalent to Oxbridge....
. Later that year, the prototype was completely rewritten in Haskell, except for its parser, by Cordelia Hall, Will Partain, and Simon Peyton Jones.






Discussion
Ask a question about 'Glasgow Haskell Compiler'
Start a new discussion about 'Glasgow Haskell Compiler'
Answer questions from other users
Full Discussion Forum



Encyclopedia


The Glorious Glasgow Haskell Compilation System, more commonly known as the Glasgow Haskell Compiler or GHC, is an open source
Open source

Open source is an approach to design, development, and distribution offering practical accessibility to a product's source . Some consider open source as one of various possible design approaches, while others consider it a critical Strategy element of their business operations....
 native code compiler
Compiler

A compiler is a computer program that transforms source code written in a programming language into another computer language . The most common reason for wanting to transform source code is to create an executable program....
 for the functional
Functional programming

In computer science, functional programming is a programming paradigm that treats computation as the evaluation of function s and avoids program state and immutable object data....
 programming
Computer programming

Computer programming is the process of writing, testing, debugging/troubleshooting, and maintaining the source code of computer programs. This source code is written in a programming language....
 language
Programming language

A programming language is a machine-readable artificial language designed to express computations that can be performed by a machine, particularly a computer....
 Haskell
Haskell (programming language)

Haskell is a standardized, purely functional programming language with non-strict programming language, named after logician Haskell Curry. The goals of the language are described as:...
. The lead developers are Simon Peyton Jones
Simon Peyton Jones

Simon Peyton Jones is a British computer scientist who researches the implementation and application software of functional programming languages, particularly lazy evaluation....
 and Simon Marlow.

History

GHC originally started in 1989 as a prototype, written in LML (Lazy ML)
Lazy ML

Lazy ML is a functional programming language developed in the early 1980s by Lennart Augustsson and Thomas Johnsson at Chalmers University of Technology, prior to Miranda programming language and Haskell ....
 by Kevin Hammond at the University of Glasgow
University of Glasgow

The University of Glasgow was founded in 1451, in Glasgow, Scotland, and, along with its contemporary institution, the University of St Andrews, it formed the Kingdom of Scotland's equivalent to Oxbridge....
. Later that year, the prototype was completely rewritten in Haskell, except for its parser, by Cordelia Hall, Will Partain, and Simon Peyton Jones. Its first beta release was on April 1, 1991 and subsequent releases added a strictness analyzer
Strictness analysis

In computer science, strictness analysis refers to any algorithm used to prove that a function in a non-strict programming language functional programming language is strict function in one or more of its arguments....
 as well as language extensions such as monadic I/O
Monads in functional programming

In functional programming, a monad is a kind of abstract data type used to represent computations . Programs written in functional style can make use of monads to structure procedures that include sequenced operations, or to define arbitrary control flows ....
, mutable arrays, unboxed data types, and a profiler
Performance analysis

In software engineering, performance analysis, more commonly today known as profiling, is the investigation of a program's behavior using information gathered as the program executes ....
.

Peyton Jones, as well as Simon Marlow, later moved to Microsoft Research
Microsoft Research

Microsoft Research is a division of Microsoft created in 1991 for researching various computer science topics and issues. It is one of the top research centers worldwide currently employing Turing Award winners C.A.R....
 in Cambridge, England, where they continue to be primarily responsible for developing GHC. GHC also contains code from more than sixty other contributors.

Architecture

GHC is itself written in Haskell (in a technique known as bootstrapping
Bootstrapping (compilers)

Bootstrapping is a term used in computer science to describe the techniques involved in writing a compiler in the target programming language which it is intended to compile....
), but the runtime system for Haskell, an essential part of the compiler, is written in C
C (programming language)

C is a general-purpose computer programming language originally developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories to implement the Unix operating system....
 and C--. Much of GHC is written in the literate programming
Literate programming

Literate programming is an approach to programming which was introduced by Donald Knuth. Knuth conceived literate programming as an alternative to the structured programming paradigm of the 1970s....
 style.

GHC's front end — incorporating the lexer
Lexer

Lexer may refer to:*Matthias von Lexer, a German lexicographer*A program performing lexical analysis...
, parser and typechecker
Type system

In computer science, a type system may be defined as "a tractable syntactic method for proving the absence of certain program behaviors by classifying phrases according to the kinds of values they compute."....
 — is designed to preserve as much information about the source language as possible until after type inference
Type inference

Type inference, or implicit typing, refers to the ability to deduce automatically the type of a value in a programming language. It is a feature present in some strongly-typed programming language static typing#Static and dynamic typing languages....
 is complete, toward the goal of providing clear error messages to users. In its last phase, the front end desugars
Syntactic sugar

Syntactic sugar is a term coined by Peter J. Landin for additions to the syntax of a computer language that do not affect its Function but make it "sweeter" for humans to use....
 Haskell into a typed intermediate language
Intermediate language

In computer science, an intermediate language is the language of an abstract machine designed to aid in the analysis of computer programs. The term comes from their use in compilers, where a compiler first translates the source code of a program into a form more suitable for code-improving transformations, as an intermediate step before gener...
 known as "Core" (based on System F
System F

System F, also known as the polymorphic lambda calculus or the second-order lambda calculus, is a typed lambda calculus. It was discovered independently by the logician Jean-Yves Girard and the computer scientist John C....
, extended with let and case expressions). Recently, Core was extended to support generalized algebraic datatypes in its type system
Type system

In computer science, a type system may be defined as "a tractable syntactic method for proving the absence of certain program behaviors by classifying phrases according to the kinds of values they compute."....
, and is now based on an extension to System F known as System FC.

In the tradition of type-directed compilation, GHC's simplifier, or "middle end", where most of the optimizations
Compiler optimization

Compiler optimization is the process of tuning the output of a compiler to minimize or maximize some attribute of an executable computer program....
 implemented in GHC are performed, is structured as a series of source-to-source
Source code

In computer science, source code is any collection of statements or declarations written in some human-readable computer programming language....
 transformations
Program transformation

A program transformation is any operation that takes a program and generates another program. It is often important that the derived program be semantically equivalent to the original, relative to a particular Formal semantics of programming languages....
 on Core code. The analyses and transformations performed in this compiler stage include demand analysis (a generalization of strictness analysis
Strictness analysis

In computer science, strictness analysis refers to any algorithm used to prove that a function in a non-strict programming language functional programming language is strict function in one or more of its arguments....
), application of user-defined rewrite rules (including a set of rules included in GHC's standard libraries that performs foldr/build fusion
Deforestation (computer science)

In the theory of programming languages in computer science, deforestation is a program transformation to eliminate tree structures.The term "deforestation" was originally coined by Philip Wadler in his paper "Deforestation: transforming programs to eliminate trees"....
), unfolding (called "inlining" in more traditional compilers), let-floating, an analysis that determines which function arguments can be unboxed, constructed product result analysis
Constructed product result analysis

In the field of compiler implementation in computer science, constructed product result analysis is a static code analysis that determines which Function in a given program can return multiple results in an efficient manner....
, specialization
Partial evaluation

In computing, partial evaluation is a technique for optimization by specialization.A computer program, prog, is seen as a mapping of input data into output data:...
 of overloaded
Type class

In computer science, a type class is a type system construct that supports Type polymorphism#Ad-hoc polymorphism. This is achieved by adding constraints to type variables in Parametric polymorphism#Parametric polymorphism types....
 functions, as well as a set of simpler local transformations such as constant folding
Constant folding

In compiler theory, constant folding and constant propagation are related compiler optimizations used by many modern compilers. A more advanced form of constant propagation known as sparse conditional constant propagation may be utilized to simultaneously remove dead code and more accurately propagate constants....
 and beta reduction.

The final stage of the simplifier transforms Core code into STG (short for "Spineless Tagless G-machine"), a lower-level intermediate language. Like Core, STG is itself a functional language. STG also corresponds to an abstract machine
Abstract machine

An abstract machine, also called an abstract computer, is a theoretical model of a computer hardware or software system used in Automata theory....
. GHC's back end performs transformations on STG before translating it into C, C--, or native machine code (the traditional "code generation" phase). Emitted C or C-- code may then be used as an intermediate language before compiling to machine code.

Language

GHC complies with the latest language standard, called Haskell 98. It also supports many optional extensions to the Haskell standard: for example, the STM
Software transactional memory

In computer science, software transactional memory is a concurrency control mechanism analogous to database transactions for controlling access to shared memory in concurrent computing....
 library, which allows for Composable Memory Transactions.

Portability

Versions of GHC are available for several platforms, including Windows
Microsoft Windows

Microsoft Windows is a series of software operating systems and graphical user interfaces produced by Microsoft. Microsoft first introduced an operating environment named Windows in November 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces ....
 and most varieties of Unix
Unix

Unix is a computer operating system originally developed in 1969 by a group of American Telephone & Telegraph employees at Bell Labs, including Ken Thompson , Dennis Ritchie, Douglas McIlroy, and Joe Ossanna....
 (such as the numerous GNU/Linux
Linux

Linux is a generic term referring to Unix-like computer operating systems based on the Linux kernel. Their development is one of the most prominent examples of free and open source software collaboration; typically all the underlying source code can be used, freely modified, and redistributed by anyone under the terms of the GNU GPL license...
 flavors and Mac OS X
Mac OS X

Mac OS X is a line of computer operating systems developed, marketed, and sold by Apple Inc., and since 2002 has been included with all new Macintosh computer systems....
). GHC has also been ported
Porting

In computer science, porting is the process of adapting software so that an executable Computer program can be created for a computing environment that is different from the one for which it was originally designed ....
 to several different processor architectures
CPU design

CPU design is the design engineering task of creating a central processing unit , a component of computer hardware. It is a subfield of electronics engineering and computer engineering....
.

External links