Haskell (programming language)

From Wikipedia for FEVERv2
Jump to navigation Jump to search

Haskell (programming language)_table_infobox_0

HaskellHaskell (programming language)_table_caption_0
ParadigmHaskell (programming language)_header_cell_0_0_0 Purely functionalHaskell (programming language)_cell_0_0_1
Designed byHaskell (programming language)_header_cell_0_1_0 Lennart Augustsson, Dave Barton, Brian Boutel, Warren Burton, Joseph Fasel, Kevin Hammond, Ralf Hinze, Paul Hudak, John Hughes, Thomas Johnsson, Mark Jones, Simon Peyton Jones, John Launchbury, Erik Meijer, John Peterson, Alastair Reid, Colin Runciman, Philip WadlerHaskell (programming language)_cell_0_1_1
First appearedHaskell (programming language)_header_cell_0_2_0 1990; 30 years ago (1990)Haskell (programming language)_cell_0_2_1
Stable releaseHaskell (programming language)_header_cell_0_3_0 Haskell 2010
  / July 2010; 10 years ago (2010-07)Haskell (programming language)_cell_0_3_1
Preview releaseHaskell (programming language)_header_cell_0_4_0 Haskell 2020 announcedHaskell (programming language)_cell_0_4_1
Typing disciplineHaskell (programming language)_header_cell_0_5_0 Inferred, static, strongHaskell (programming language)_cell_0_5_1
OSHaskell (programming language)_header_cell_0_6_0 Cross-platformHaskell (programming language)_cell_0_6_1
Haskell (programming language)_header_cell_0_7_0 .hs, .lhsHaskell (programming language)_cell_0_7_1
WebsiteHaskell (programming language)_header_cell_0_8_0 Haskell (programming language)_cell_0_8_1
Major implementationsHaskell (programming language)_header_cell_0_9_0
DialectsHaskell (programming language)_header_cell_0_10_0
Influenced byHaskell (programming language)_header_cell_0_11_0
InfluencedHaskell (programming language)_header_cell_0_12_0

Haskell /ˈhæskəl/ is a general-purpose, statically typed, purely functional programming language with type inference and lazy evaluation. Haskell (programming language)_sentence_0

Developed to be suitable for teaching, research and industrial application, Haskell has pioneered a number of advanced programming language features such as type classes, which enable type-safe operator overloading. Haskell (programming language)_sentence_1

Haskell's main implementation is the Glasgow Haskell Compiler (GHC). Haskell (programming language)_sentence_2

It is named after logician Haskell Curry. Haskell (programming language)_sentence_3

Haskell's semantics are historically based on those of the Miranda programming language, which served to focus the efforts of the initial Haskell working group. Haskell (programming language)_sentence_4

The last formal specification of the language was made in July 2010, while the development of GHC's implementation has continued to extend Haskell via language extensions. Haskell (programming language)_sentence_5

The next formal specification is planned for 2020. Haskell (programming language)_sentence_6

Haskell is used in academia and industry. Haskell (programming language)_sentence_7

As of September 2019, Haskell was the 23rd most popular programming language in terms of Google searches for tutorials and made up less than 1% of active users on the GitHub source code repository. Haskell (programming language)_sentence_8

History Haskell (programming language)_section_0

Following the release of Miranda by Research Software Ltd. in 1985, interest in lazy functional languages grew. Haskell (programming language)_sentence_9

By 1987, more than a dozen non-strict, purely functional programming languages existed. Haskell (programming language)_sentence_10

Miranda was the most widely used, but it was proprietary software. Haskell (programming language)_sentence_11

At the conference on Functional Programming Languages and Computer Architecture (FPCA '87) in Portland, Oregon, there was a strong consensus that a committee be formed to define an open standard for such languages. Haskell (programming language)_sentence_12

The committee's purpose was to consolidate existing functional languages into a common one to serve as a basis for future research in functional-language design. Haskell (programming language)_sentence_13

Haskell 1.0 to 1.4 Haskell (programming language)_section_1

Type classes, which enable type-safe operator overloading, were first proposed by Philip Wadler and Stephen Blott for Standard ML but were first implemented in Haskell between 1987 and version 1.0. Haskell (programming language)_sentence_14

The first version of Haskell ("Haskell 1.0") was defined in 1990. Haskell (programming language)_sentence_15

The committee's efforts resulted in a series of language definitions (1.0, 1.1, 1.2, 1.3, 1.4). Haskell (programming language)_sentence_16

Haskell 98 Haskell (programming language)_section_2

In late 1997, the series culminated in Haskell 98, intended to specify a stable, minimal, portable version of the language and an accompanying standard library for teaching, and as a base for future extensions. Haskell (programming language)_sentence_17

The committee expressly welcomed creating extensions and variants of Haskell 98 via adding and incorporating experimental features. Haskell (programming language)_sentence_18

In February 1999, the Haskell 98 language standard was originally published as The Haskell 98 Report. Haskell (programming language)_sentence_19

In January 2003, a revised version was published as Haskell 98 Language and Libraries: The Revised Report. Haskell (programming language)_sentence_20

The language continues to evolve rapidly, with the Glasgow Haskell Compiler (GHC) implementation representing the current de facto standard. Haskell (programming language)_sentence_21

Haskell 2010 Haskell (programming language)_section_3

In early 2006, the process of defining a successor to the Haskell 98 standard, informally named Haskell Prime, began. Haskell (programming language)_sentence_22

This was intended to be an ongoing incremental process to revise the language definition, producing a new revision up to once per year. Haskell (programming language)_sentence_23

The first revision, named Haskell 2010, was announced in November 2009 and published in July 2010. Haskell (programming language)_sentence_24

Haskell 2010 is an incremental update to the language, mostly incorporating several well-used and uncontroversial features previously enabled via compiler-specific flags. Haskell (programming language)_sentence_25

Haskell (programming language)_unordered_list_0

  • Hierarchical module names. Module names are allowed to consist of dot-separated sequences of capitalised identifiers, rather than only one such identifier. This lets modules be named in a hierarchical manner (e.g., Data.List instead of List), although technically modules are still in a single monolithic namespace. This extension was specified in an addendum to Haskell 98 and was in practice universally used.Haskell (programming language)_item_0_0
  • The foreign function interface (FFI) allows bindings to other programming languages. Only bindings to C are specified in the Report, but the design allows for other language bindings. To support this, data type declarations were permitted to contain no constructors, enabling robust nonce types for foreign data that could not be constructed in Haskell. This extension was also previously specified in an Addendum to the Haskell 98 Report and widely used.Haskell (programming language)_item_0_1
  • So-called n+k patterns (definitions of the form fact (n+1) = (n+1) * fact n) were no longer allowed. This syntactic sugar had misleading semantics, in which the code looked like it used the (+) operator, but in fact desugared to code using (-) and (>=).Haskell (programming language)_item_0_2
  • The rules of type inference were relaxed to allow more programs to type check.Haskell (programming language)_item_0_3
  • Some syntax issues (changes in the formal grammar) were fixed: pattern guards were added, allowing pattern matching within guards; resolution of operator fixity was specified in a simpler way that reflected actual practice; an edge case in the interaction of the language's lexical syntax of operators and comments was addressed, and the interaction of do-notation and if-then-else was tweaked to eliminate unexpected syntax errors.Haskell (programming language)_item_0_4
  • The LANGUAGE pragma was specified. By 2010 dozens of extensions to the language were in wide use, and GHC (among other compilers) provided the LANGUAGE pragma to specify individual extensions with a list of identifiers. Haskell 2010 compilers are required to support the Haskell2010 extension and are encouraged to support several others, which correspond to extensions added in Haskell 2010.Haskell (programming language)_item_0_5

Features Haskell (programming language)_section_4

Main article: Haskell features Haskell (programming language)_sentence_26

See also: Glasgow Haskell Compiler § Extensions to Haskell Haskell (programming language)_sentence_27

Haskell features lazy evaluation, lambda expressions, pattern matching, list comprehension, type classes and type polymorphism. Haskell (programming language)_sentence_28

It is a purely functional language, which means that functions generally have no side effects. Haskell (programming language)_sentence_29

A distinct construct exists to represent side effects, orthogonal to the type of functions. Haskell (programming language)_sentence_30

A pure function can return a side effect that is subsequently executed, modeling the impure functions of other languages. Haskell (programming language)_sentence_31

Haskell has a strong, static type system based on Hindley–Milner type inference. Haskell (programming language)_sentence_32

Its principal innovation in this area is type classes, originally conceived as a principled way to add overloading to the language, but since finding many more uses. Haskell (programming language)_sentence_33

The construct that represents side effects is an example of a monad. Haskell (programming language)_sentence_34

Monads are a general framework that can model different kinds of computation, including error handling, nondeterminism, parsing and software transactional memory. Haskell (programming language)_sentence_35

Monads are defined as ordinary datatypes, but Haskell provides some syntactic sugar for their use. Haskell (programming language)_sentence_36

Haskell has an open, published specification, and multiple implementations exist. Haskell (programming language)_sentence_37

Its main implementation, the Glasgow Haskell Compiler (GHC), is both an interpreter and native-code compiler that runs on most platforms. Haskell (programming language)_sentence_38

GHC is noted for its rich type system incorporating recent innovations such as generalized algebraic data types and type families. Haskell (programming language)_sentence_39

The Computer Language Benchmarks Game also highlights its high-performance implementation of concurrency and parallelism. Haskell (programming language)_sentence_40

An active, growing community exists around the language, and more than 5,400 third-party open-source libraries and tools are available in the online package repository Hackage. Haskell (programming language)_sentence_41

Code examples Haskell (programming language)_section_5

See also: Haskell features § Examples Haskell (programming language)_sentence_42

A "Hello, World!" Haskell (programming language)_sentence_43 program in Haskell (only the last line is strictly necessary): Haskell (programming language)_sentence_44

The factorial function in Haskell, defined in a few different ways: Haskell (programming language)_sentence_45

As the Integer type has arbitrary-precision, this code will compute values such as factorial 100000 (a 456,574-digit number), with no loss of precision. Haskell (programming language)_sentence_46

An implementation of an algorithm similar to quick sort over lists, where the first element is taken as the pivot: Haskell (programming language)_sentence_47

Implementations Haskell (programming language)_section_6

All listed implementations are distributed under open source licenses. Haskell (programming language)_sentence_48

Implementations that fully or nearly comply with the Haskell 98 standard, include: Haskell (programming language)_sentence_49

Haskell (programming language)_unordered_list_1

  • The Glasgow Haskell Compiler (GHC) compiles to native code on many different processor architectures, and to ANSI C, via one of two intermediate languages: C--, or in more recent versions, LLVM (formerly Low Level Virtual Machine) bitcode. GHC has become the de facto standard Haskell dialect. There are libraries (e.g., bindings to OpenGL) that work only with GHC. GHC is also distributed with the Haskell platform.Haskell (programming language)_item_1_6
  • Jhc, a Haskell compiler written by John Meacham, emphasizes speed and efficiency of generated programs and exploring new program transformations.Haskell (programming language)_item_1_7
    • Ajhc is a fork of Jhc.Haskell (programming language)_item_1_8
  • The Utrecht Haskell Compiler (UHC) is a Haskell implementation from Utrecht University. It supports almost all Haskell 98 features plus many experimental extensions. It is implemented using attribute grammars and is currently used mostly for research on generated type systems and language extensions.Haskell (programming language)_item_1_9

Implementations no longer actively maintained include: Haskell (programming language)_sentence_50

Haskell (programming language)_unordered_list_2

  • The Haskell User's Gofer System (Hugs) is a bytecode interpreter. It was once one of the implementations used most widely, alongside the GHC compiler, but has now been mostly replaced by GHCi. It also comes with a graphics library.Haskell (programming language)_item_2_10
  • HBC is an early implementation supporting Haskell 1.4. It was implemented by Lennart Augustsson in, and based on, Lazy ML. It has not been actively developed for some time.Haskell (programming language)_item_2_11
  • nhc98 is a bytecode compiler focusing on minimizing memory use.Haskell (programming language)_item_2_12
    • The York Haskell Compiler (Yhc) was a fork of nhc98, with the goals of being simpler, more portable and efficient, and integrating support for Hat, the Haskell tracer. It also had a JavaScript backend, allowing users to run Haskell programs in web browsers.Haskell (programming language)_item_2_13

Implementations not fully Haskell 98 compliant, and using a variant Haskell language, include: Haskell (programming language)_sentence_51

Haskell (programming language)_unordered_list_3

  • Eta and Frege are dialects of Haskell targeting the Java Virtual Machine.Haskell (programming language)_item_3_14
  • Gofer was an educational dialect of Haskell, with a feature called constructor classes, developed by Mark Jones. It was supplanted by Hugs (Haskell User's Gofer System).Haskell (programming language)_item_3_15
  • Helium, a newer dialect of Haskell. The focus is on making learning easier via clearer error messages. It currently lacks full support for type classes, rendering it incompatible with many Haskell programs.Haskell (programming language)_item_3_16

Notable applications Haskell (programming language)_section_7

Haskell (programming language)_unordered_list_4

  • Cabal is a tool for building and packaging Haskell libraries and programs.Haskell (programming language)_item_4_17
  • Darcs is a revision control system written in Haskell, with several innovative features, such as more precise control of patches to apply.Haskell (programming language)_item_4_18
  • GHC is also often a testbed for advanced functional programming features and optimizations in other programming languages.Haskell (programming language)_item_4_19
  • Git-annex is a tool to manage (big) data files under Git version control. It also provides a distributed file synchronization system (git-annex assistant).Haskell (programming language)_item_4_20
  • Linspire GNU/Linux chose Haskell for system tools development.Haskell (programming language)_item_4_21
  • Pandoc is a tool to convert one markup format into another.Haskell (programming language)_item_4_22
  • Pugs is a compiler and interpreter for the Raku programming language (formerly Perl 6).Haskell (programming language)_item_4_23
  • Xmonad is a window manager for the X Window System, written fully in Haskell.Haskell (programming language)_item_4_24

Industry Haskell (programming language)_section_8

Haskell (programming language)_unordered_list_5

  • Bluespec SystemVerilog (BSV) is a language for semiconductor design that is an extension of Haskell. Also, Bluespec, Inc.'s tools are implemented in Haskell.Haskell (programming language)_item_5_25
  • Cryptol, a language and toolchain for developing and verifying cryptography algorithms, is implemented in Haskell.Haskell (programming language)_item_5_26
  • Facebook implements its anti-spam programs in Haskell, maintaining the underlying data access library as open-source software.Haskell (programming language)_item_5_27
  • GitHub implemented Semantic, an open-source library for analysis, diffing, and interpretation of untrusted source code, in Haskell.Haskell (programming language)_item_5_28
  • seL4, the first formally verified microkernel, used Haskell as a prototyping language for the OS developer. At the same time, the Haskell code defined an executable specification with which to reason, for automatic translation by the theorem-proving tool. The Haskell code thus served as an intermediate prototype before final C refinement.Haskell (programming language)_item_5_29

Web Haskell (programming language)_section_9

Notable web frameworks written for Haskell include: Haskell (programming language)_sentence_52

Haskell (programming language)_unordered_list_6

  • SnapHaskell (programming language)_item_6_30
  • YesodHaskell (programming language)_item_6_31

Criticism Haskell (programming language)_section_10

Jan-Willem Maessen, in 2002, and Simon Peyton Jones, in 2003, discussed problems associated with lazy evaluation while also acknowledging the theoretical motives for it. Haskell (programming language)_sentence_53

In addition to purely practical considerations such as improved performance, they note that, in addition to adding some performance overhead, lazy evaluation makes it more difficult for programmers to reason about the performance of their code (particularly its space use). Haskell (programming language)_sentence_54

Bastiaan Heeren, Daan Leijen, and Arjan van IJzendoorn in 2003 also observed some stumbling blocks for Haskell learners: "The subtle syntax and sophisticated type system of Haskell are a double edged sword – highly appreciated by experienced programmers but also a source of frustration among beginners, since the generality of Haskell often leads to cryptic error messages." Haskell (programming language)_sentence_55

To address these, researchers from Utrecht University developed an advanced interpreter called Helium, which improved the user-friendliness of error messages by limiting the generality of some Haskell features, and in particular removing support for type classes. Haskell (programming language)_sentence_56

Ben Lippmeier designed Disciple as a strict-by-default (lazy by explicit annotation) dialect of Haskell with a type-and-effect system, to address Haskell's difficulties in reasoning about lazy evaluation and in using traditional data structures such as mutable arrays. Haskell (programming language)_sentence_57

He argues (p. 20) that "destructive update furnishes the programmer with two important and powerful tools ... a set of efficient array-like data structures for managing collections of objects, and ... the ability to broadcast a new value to all parts of a program with minimal burden on the programmer." Haskell (programming language)_sentence_58

Robert Harper, one of the authors of Standard ML, has given his reasons for not using Haskell to teach introductory programming. Haskell (programming language)_sentence_59

Among these are the difficulty of reasoning about resource use with non-strict evaluation, that lazy evaluation complicates the definition of data types and inductive reasoning, and the "inferiority" of Haskell's (old) class system compared to ML's module system. Haskell (programming language)_sentence_60

Haskell's build tool, Cabal, has historically been criticised for poorly handling multiple versions of the same library, a problem known as "Cabal hell". Haskell (programming language)_sentence_61

The Stackage server and Stack build tool were made in response to these criticisms. Haskell (programming language)_sentence_62

Cabal itself now has a much more sophisticated build system, heavily inspired by Nix, which became the default with version 3.0. Haskell (programming language)_sentence_63

Related languages Haskell (programming language)_section_11

Clean is a close, slightly older relative of Haskell. Haskell (programming language)_sentence_64

Its biggest deviation from Haskell is in the use of uniqueness types instead of monads for I/O and side-effects. Haskell (programming language)_sentence_65

A series of languages inspired by Haskell, but with different type systems, have been developed, including: Haskell (programming language)_sentence_66

Haskell (programming language)_unordered_list_7

  • Agda, a functional language with dependent types.Haskell (programming language)_item_7_32
  • Cayenne, with dependent types.Haskell (programming language)_item_7_33
  • Elm, a functional language to create web front-end apps, no support for higher-kinded types.Haskell (programming language)_item_7_34
  • Epigram, a functional language with dependent types suitable for proving properties of programs.Haskell (programming language)_item_7_35
  • Idris, a general purpose functional language with dependent types, developed at the University of St Andrews.Haskell (programming language)_item_7_36
  • PureScript compiles to JavaScript.Haskell (programming language)_item_7_37
  • Ωmega, strict and more.Haskell (programming language)_item_7_38

Other related languages include: Haskell (programming language)_sentence_67

Haskell (programming language)_unordered_list_8

  • Curry, a functional/logic programming language based on Haskell.Haskell (programming language)_item_8_39

Notable Haskell variants include: Haskell (programming language)_sentence_68

Haskell (programming language)_unordered_list_9

  • Generic Haskell, a version of Haskell with type system support for generic programming.Haskell (programming language)_item_9_40
  • Hume, a strict functional language for embedded systems based on processes as stateless automata over a sort of tuples of one element mailbox channels where the state is kept by feedback into the mailboxes, and a mapping description from outputs to channels as box wiring, with a Haskell-like expression language and syntax.Haskell (programming language)_item_9_41

Conferences and workshops Haskell (programming language)_section_12

The Haskell community meets regularly for research and development activities. Haskell (programming language)_sentence_69

The main events are: Haskell (programming language)_sentence_70

Haskell (programming language)_unordered_list_10

Since 2006, a series of organized hackathons has occurred, the Hac series, aimed at improving the programming language tools and libraries. Haskell (programming language)_sentence_71

Credits to the contents of this page go to the authors of the corresponding Wikipedia page: en.wikipedia.org/wiki/Haskell (programming language).