Changes

Jump to navigation Jump to search
40,475 bytes removed ,  22:56, December 23, 2018
revert vandalism
Line 1: Line 1: −
'''Haskell''' {{IPAc-en|ˈ|h|æ|s|k|əl}}<ref>{{cite mailing list |url=http://www.haskell.org/pipermail/haskell-cafe/2008-January/038756.html |title=anybody can tell me the pronunciation of "haskell"? |date=28 January 2008 |accessdate=12 March 2011 |mailinglist=Haskell-cafe |last=Chevalier |first=Tim}}</ref> is a standardized, [[General-purpose programming language|general-purpose]], [[purely functional programming]] language with [[non-strict semantics]] and [[Strong typing|strong]] [[static typing]].{{sfn|Peyton Jones|2003}} It is named after [[logician]] [[Haskell Curry]].{{sfn|Hudak|Hughes|Peyton Jones|Wadler|2007}} The latest standard of Haskell is Haskell 2010. {{As of|2016|05}}, a group is working on the next version, Haskell 2020.<ref>https://mail.haskell.org/pipermail/haskell-prime/2016-April/004050.html</ref>
+
'''Haskell''' is a pure [[functional programming languages|functional programming language]] with roots in [[category theory]].  Free and [[open source]] implementations are available for a variety of operating systems.
   −
Haskell features a [[type system]] with [[type inference]]<ref>Type inference originally using [[Type inference#Hindley.E2.80.93Milner type inference algorithm|Hindley-Milner type inference]]</ref> and [[lazy evaluation]].<ref>This allows finer control over the expression [[evaluation strategy]]</ref> [[Type classes]]  first appeared in the Haskell programming language.<ref>"Type classes, first proposed during the design of the Haskell programming language, ..."&nbsp;—[https://jgbm.github.io/pubs/morris-dissertation.pdf John Garrett Morris (2013), "Type Classes and Instance Chains: A Relational Approach" ]</ref> Its main implementation is the [[Glasgow Haskell Compiler]].
+
==Functions in Haskell==
   −
Haskell is based on the [[Semantics of programming languages|semantics]], but not the syntax, of the language [[Miranda (programming language)|Miranda]], which served to focus the efforts of the initial Haskell working group.<ref>Edward Kmett, [https://www.youtube.com/watch?v=hIZxTQP1ifo  Edward Kmett - Type Classes vs. the World]</ref> Haskell is used widely in academia<ref>{{cite web|url=https://wiki.haskell.org/Haskell_in_education|title=Haskell in education|publisher=|accessdate=15 February 2016}}</ref><ref>{{cite web|url=https://wiki.haskell.org/Haskell_in_research|title=Haskell in research|publisher=|accessdate=15 February 2016}}</ref> and industry.<ref>{{cite web|url=https://wiki.haskell.org/Haskell_in_industry|title=Haskell in industry|publisher=|accessdate=15 February 2016}}</ref>
+
Functions are the most important idea in Haskell. A function takes a single value as input and returns a single value as output. Clearly it is often desirable to take in more than one argument or give out more than one. This can be done using [[tuples]] or [[lists]] but there is a very mathematically elegant and useful method called [[currying]], named for the logician Haskell Curry.
   −
==History==
+
Functions in Haskell are also values in themselves, allowing Haskell to use [[higher-order functions]].
Following the release of [[Miranda (programming language)|Miranda]] by Research Software Ltd. in 1985, interest in [[Lazy evaluation|lazy functional languages]] grew. By 1987, more than a dozen [[non-strict]], purely functional programming languages existed. Miranda was the most widely used, but it was [[proprietary software]]. 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. 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.{{sfn|Peyton Jones|2003|loc=Preface}}
     −
===Haskell 1.0 to 1.4===
+
== Hello World ==
<!-- To do: Describe the change-over in I/O, from lazy streams to monads. -->
  −
The first version of Haskell ("Haskell 1.0") was defined in 1990.{{sfn|Hudak|Hughes|Peyton Jones|Wadler|2007}} The committee's efforts resulted in a series of language definitions (1.0, 1.1, 1.2, 1.3, 1.4).
     −
===Haskell 98===
+
(display "hello world\n")
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 (computer science)|library]] for teaching, and as a base for future extensions. The committee expressly welcomed creating extensions and variants of Haskell 98 via adding and incorporating experimental features.{{sfn|Peyton Jones|2003|loc=Preface}}
     −
In February 1999, the Haskell 98 language standard was originally published as ''The Haskell 98 Report''.{{sfn|Peyton Jones|2003|loc=Preface}} In January 2003, a revised version was published as ''Haskell 98 Language and Libraries: The Revised Report''.{{sfn|Peyton Jones|2003}} The language continues to evolve rapidly, with the [[Glasgow Haskell Compiler]] (GHC) implementation representing the current ''de facto'' standard.<ref name=HaskellWikiImpl>{{cite web|title=Haskell Wiki: Implementations|url=http://www.haskell.org/haskellwiki/Implementations|accessdate=18 December 2012}}</ref>
+
===External links===
 +
* [http://www.haskell.org The HaskellWiki]
   −
===Haskell 2010===
+
[[Category:Programming Languages]]
In early 2006, the process of defining a successor to the Haskell 98 standard, informally named ''Haskell Prime'', began.<ref>{{cite web|url=https://prime.haskell.org/|title=Welcome to Haskell'|work=The Haskell' Wiki}}</ref> This was intended to be an ongoing incremental process to revise the language definition, producing a new revision up to once per year.  The first revision, named '''Haskell 2010''', was announced in November 2009<ref name="2010ann"/> and published in July 2010.
  −
 
  −
Haskell 2010 is an incremental update to the language, mostly incorporating several well-used and uncontroversial features previously enabled via compiler-specific flags.
  −
* 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., <code>Data.List</code> instead of <code>List</code>), 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.
  −
* The [[foreign function interface]] (FFI) allows bindings to other programming languages. Only bindings to [[C (programming language)|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.
  −
* So-called ''n''+''k'' patterns (definitions of the form <code>fact (n+1) = (n+1) * fact n</code>) were no longer allowed. This [[syntactic sugar]] had misleading semantics, in which the code looked like it used the <code>(+)</code> operator, but in fact desugared to code using <code>(-)</code> and <code>(>=)</code>.
  −
* The rules of [[type inference]] were relaxed to allow more programs to type check.
  −
* Some [[Syntax (programming languages)|syntax]] issues (changes in the formal grammar) were fixed: pattern guards were added, allowing pattern matching within guards; resolution of [[Order of operations|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.
  −
* The <code>LANGUAGE</code> [[Directive (programming)|pragma]] was specified. By 2010 dozens of extensions to the language were in wide use, and GHC (among other compilers) provided the <code>LANGUAGE</code> pragma to specify individual extensions with a list of identifiers. Haskell 2010 compilers are required to support the <code>Haskell2010</code> extension, and are encouraged to support several others which correspond to extensions added in Haskell 2010.
  −
 
  −
==Features==
  −
{{Main|Haskell features}}
  −
{{See also|Glasgow Haskell Compiler#Extensions to Haskell}}
  −
 
  −
Haskell features [[lazy evaluation]], lambda expressions, [[pattern matching]], [[list comprehension]], [[type class]]es and [[type polymorphism]]. It is a [[purely functional language]], which means that functions generally have no [[Side effect (computer science)|side effects]]. A distinct construct exists to represent side effects, [[Orthogonal#Computer science|orthogonal]] to the type of functions. A pure function can return a side effect that is subsequently executed, modeling the [[Pure function#Impure functions|impure functions]] of other languages.
  −
 
  −
Haskell has a [[strongly typed programming language|strong]], [[static type#Static typing|static]] type system based on [[Hindley–Milner type inference]]. Its principal innovation in this area is type classes, originally conceived as a principled way to add [[Polymorphism (computer science)|overloading]] to the language,<ref name="wadler89">{{cite journal|last1=Wadler|first1=P.|first2=S. |last2=Blott|year=1989|title=How to make ad-hoc polymorphism less ad hoc|journal=Proceedings of the 16th ACM [[SIGPLAN]]-[[SIGACT]] [[Symposium on Principles of Programming Languages]]|publisher=[[Association for Computing Machinery|ACM]]|pages=60–76|doi=10.1145/75277.75283|isbn=0-89791-294-2}}</ref> but since finding many more uses.<ref name="hallgren01">{{cite journal|last=Hallgren|first=T.|date=January 2001|title=Fun with Functional Dependencies, or Types as Values in Static Computations in Haskell|journal=Proceedings of the Joint CS/CE Winter Meeting|location=Varberg, Sweden|url=http://www.cs.chalmers.se/~hallgren/Papers/wm01.html}}</ref>
  −
 
  −
The construct that represents side effects is an example of a [[Monad (functional programming)|monad]]. Monads are a general framework that can model different kinds of computation, including error handling, [[Nondeterministic algorithm|nondeterminism]], [[parsing]] and [[software transactional memory]]. Monads are defined as ordinary datatypes, but Haskell provides some [[syntactic sugar]] for their use.
  −
 
  −
Haskell has an open, published specification,{{sfn|Peyton Jones|2003}} and [[#Implementations|multiple implementations exist]]. Its main implementation, the [[Glasgow Haskell Compiler]] (GHC), is both an [[Interpreter (computing)|interpreter]] and [[Machine code|native-code]] [[compiler]] that runs on most platforms. GHC is noted for its rich type system incorporating recent innovations such as [[generalized algebraic data type]]s and type families. [[The Computer Language Benchmarks Game]] also highlights its high-performance implementation of [[Concurrency (computer science)|concurrency]] and [[Parallel computing|parallelism]].<ref name="shootout">[http://benchmarksgame.alioth.debian.org/u64q/haskell.html Computer Language Benchmarks Game]</ref>
  −
 
  −
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''.<ref name="hackage-stats">{{cite web|url=http://hackage.haskell.org/cgi-bin/hackage-scripts/stats|archiveurl=https://web.archive.org/web/20130503114836/http://hackage.haskell.org/cgi-bin/hackage-scripts/stats|archivedate=2013-05-03 |title=HackageDB statistics |publisher=Hackage.haskell.org |accessdate=2013-06-26}}</ref>
  −
 
  −
==Code examples==
  −
{{See also|Haskell features#Examples}}
  −
A [[Hello world program|"Hello world" program]] in Haskell (only the last line is strictly necessary):
  −
<source lang="haskell">
  −
module Main (main) where          -- not needed in interpreter, is the default in a module file
  −
 
  −
main :: IO ()                      -- the compiler can infer this type definition
  −
main = putStrLn "Hello, World!"
  −
</source>
  −
 
  −
The [[factorial]] function in Haskell, defined in a few different ways:
  −
<source lang="haskell">
  −
-- Type annotation (optional, same for each implementation)
  −
factorial :: (Integral a) => a -> a
  −
 
  −
-- Using recursion (with the "ifthenelse" expression)
  −
factorial n = if n < 2
  −
              then 1
  −
              else n * factorial (n - 1)
  −
 
  −
-- Using recursion (with pattern matching)
  −
factorial 0 = 1
  −
factorial n = n * factorial (n - 1)
  −
 
  −
-- Using recursion (with guards)
  −
factorial n
  −
  | n < 2    = 1
  −
  | otherwise = n * factorial (n - 1)
  −
 
  −
-- Using a list and the "product" function
  −
factorial n = product [1..n]
  −
 
  −
-- Using fold (implements "product")
  −
factorial n = foldl (*) 1 [1..n]
  −
 
  −
-- Point-free style
  −
factorial = foldr (*) 1 . enumFromTo 1
  −
</source>
  −
Because the ''Integer'' type has [[arbitrary-precision]], this code will compute values such as <code>factorial 100000</code> (a 456,574-digit number), with no loss of precision.
  −
 
  −
 
  −
An implementation of an algorithm similar to [[quick sort]] over lists, where the first element is taken as the pivot:
  −
<source lang="haskell">
  −
-- Type annotation (optional, same for each implementation)
  −
quickSort :: Ord a => [a] -> [a]
  −
 
  −
-- Using list comprehensions
  −
quickSort []    = []                              -- The empty list is already sorted
  −
quickSort (x:xs) = quickSort [a | a <- xs, a < x]  -- Sort the left part of the list
  −
                  ++ [x] ++                        -- Insert pivot between two sorted parts
  −
                  quickSort [a | a <- xs, a >= x]  -- Sort the right part of the list
  −
 
  −
-- Using filter
  −
quickSort []    = []
  −
quickSort (x:xs) = quickSort (filter (<x) xs)
  −
                  ++ [x] ++
  −
                  quickSort (filter (>=x) xs)
  −
</source>
  −
 
  −
==Implementations==
  −
<!-- To anyone wishing to expand or improve this section: the article "A History of Haskell: Being Lazy With Class", linked to in the Further reading section contains detailed descriptions of all implementations. -->
  −
All listed implementations are distributed under [[open source license]]s.<ref name="implementations">[http://www.haskell.org/haskellwiki/Implementations "Implementations"] at the Haskell Wiki</ref>
  −
 
  −
Implementations that fully or nearly comply with the Haskell 98 standard, include:
  −
* The ''[[Glasgow Haskell Compiler]]'' (GHC) compiles to native code on many different processor architectures, and to [[ANSI C]], via one of two [[intermediate language]]s: [[C--]], or in more recent versions, [[LLVM]] (formerly Low Level Virtual Machine) bitcode.<ref>{{cite web|
  −
url=https://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler/Backends/LLVM|
  −
title=The LLVM Backend|
  −
website=GHC Trac}}</ref><ref>{{cite conference
  −
| url = http://www.cse.unsw.edu.au/~chak/papers/TC10.html
  −
| title = An LLVM Backend for GHC
  −
| last1 = Terei
  −
| first1 = David A.
  −
| last2 = Chakravarty
  −
| first2 = Manuel M. T.
  −
| date = 2010
  −
| publisher = ACM Press
  −
| book-title = Proceedings of ACM SIGPLAN Haskell Symposium 2010}}</ref> GHC has become the ''de facto'' standard Haskell dialect.<ref>C. Ryder and S. Thompson (2005). [http://kar.kent.ac.uk/14237/1/Tech_Chris.pdf "Porting HaRe to the GHC API"]</ref> There are libraries (e.g., bindings to [[OpenGL]]) that work only with GHC. GHC is also distributed with the [[Haskell platform]].
  −
* The ''Utrecht Haskell Compiler'' (UHC) is a Haskell implementation from [[Utrecht University]].<ref>[http://www.cs.uu.nl/wiki/UHC Utrecht Haskell Compiler]</ref> It supports almost all Haskell 98 features plus many experimental extensions. It is implemented using [[attribute grammar]]s and is currently used mostly for research on generated type systems and language extensions.
  −
* ''Jhc'', a Haskell compiler written by John Meacham, emphasizes speed and efficiency of generated programs and exploring new program transformations.
  −
** ''Ajhc'' is a fork of Jhc.
  −
* ''LHC'' is a whole-program optimizing backend for GHC, based on Urban Boquist’s compiler intermediate language, GRIN.<ref>{{cite journal |last=Boquist |first=Urban |author2=Johnsson, Thomas |title=The GRIN Project: A Highly Optimising Back End for Lazy Functional Languages |journal=LNCS |year=1996 |volume=1268 |pages=58–84}}</ref> Older versions of LHC were based on Jhc rather than GHC.
  −
 
  −
Implementations no longer actively maintained include:
  −
* 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,{{sfn|Hudak|Hughes|Peyton Jones|Wadler|2007|p=12-22}} but has now been mostly replaced by GHCi. It also comes with a graphics library.
  −
* ''nhc98'' is a bytecode compiler focusing on minimizing memory use.
  −
** 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 browser]]s.
  −
* ''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.
  −
 
  −
Implementations not fully Haskell 98 compliant, and using a variant Haskell language, include:
  −
* ''[[Gofer (software)|Gofer]]'' was an educational dialect of Haskell, with a feature called ''constructor classes'', developed by Mark Jones. It was supplanted by Hugs (see above).
  −
* ''[[Helium (Haskell)|Helium]]'' is 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.
  −
*Eta and [[Frege (programming language)|Frege]] are dialects of Haskell targeting the [[Java virtual machine|Java Virtual Machine]].
  −
 
  −
==Applications==
  −
* [[Darcs]] is a [[revision control system]] written in Haskell, with several innovative features, such as more precise control of patches to apply.
  −
* [[Cabal (software)|Cabal]] is a tool for [[Build automation|building]] and packaging Haskell libraries and programs.<ref>{{cite web|url=https://www.haskell.org/cabal/|title=The Haskell Cabal|accessdate=8 April 2015}}</ref>
  −
* [[Linspire]] GNU/Linux chose Haskell for system tools development.<ref>{{cite web|url=http://urchin.earth.li/pipermail/debian-haskell/2006-May/000169.html|title=Linspire/Freespire Core OS Team and Haskell|work=Debian Haskell mailing list|date=May 2006}}</ref>
  −
* [[Xmonad]] is a [[window manager]] for the [[X Window System]], written fully in Haskell.<ref>xmonad.org</ref>
  −
* [[Glasgow Haskell Compiler|GHC]] is also often a testbed for advanced functional programming features and optimizations in other programming languages.
  −
* [[Pandoc]] is a tool to convert one markup format into another.
  −
* The Shake build system, aiming to be reliable, robust, and fast.<ref>[http://shakebuild.com/ Shake Build System]</ref>
  −
* ShellCheck - A shell script static analysis tool.<ref>[https://github.com/koalaman/shellcheck/ ShellCheck]</ref>
  −
 
  −
===Industry===
  −
* [[Facebook]] implements its anti-spam programs<ref>{{cite web |title = Facebook’s New Spam-Killer Hints at the Future of Coding |url = https://www.wired.com/2015/09/facebooks-new-anti-spam-system-hints-future-coding/ |accessdate = September 1, 2015 |date = September 1, 2015 |website = [[Wired (magazine)|Wired]] |publisher = |last = Metz |first = Cade}}</ref> in Haskell, as [[open-source software]].<ref>[https://code.facebook.com/posts/302060973291128/open-sourcing-haxl-a-library-for-haskell/ Simon Marlow (2014),  Open-sourcing Haxl]</ref>
  −
* [[Swift Navigation]], a high precision GPS manufacturer, implements significant portions of its product in Haskell, providing some [[open source software]].<ref>[https://github.com/swift-nav/wolf/ Swift-Nav (2018)]</ref>
  −
* [[Bluespec, Inc.|Bluespec]] SystemVerilog (BSV) is a language for semiconductor design that is an extension of Haskell. Also, Bluespec, Inc.'s tools are implemented in Haskell.
  −
* [[Cryptol]], a language and toolchain for developing and verifying [[cryptography]] algorithms, is implemented in Haskell.
  −
* [[seL4]], the first [[Formal methods|formally verified]] [[microkernel]],<ref name="klein-sosp09">
  −
A formal proof of functional correctness was completed in 2009.
  −
{{ cite conference
  −
| first1 = Gerwin
  −
| last1 = Klein
  −
| first2 = Kevin
  −
| last2 = Elphinstone
  −
| first3 = Gernot
  −
| last3 = Heiser
  −
| author3-link = Gernot Heiser
  −
| first4 = June
  −
| last4 = Andronick
  −
| first5 = David
  −
| last5 = Cock
  −
| first6 = Philip
  −
| last6 = Derrin
  −
| first7 = Dhammika
  −
| last7 = Elkaduwe
  −
| first8 = Kai
  −
| last8 = Engelhardt
  −
| first9 = Rafal
  −
| last9 = Kolanski
  −
| first10 = Michael
  −
| last10 = Norrish
  −
| first11 = Thomas
  −
| last11 = Sewell
  −
| first12 = Harvey
  −
| last12 = Tuch
  −
| first13 = Simon
  −
| last13 = Winwood
  −
| title = seL4: Formal verification of an OS kernel
  −
| booktitle = 22nd ACM Symposium on Operating System Principles
  −
|date=October 2009
  −
| location = Big Sky, MT, USA
  −
| doi =
  −
| url = http://www.sigops.org/sosp/sosp09/papers/klein-sosp09.pdf
  −
}}
  −
</ref> used Haskell as a prototyping language for the OS developer.<ref name="klein-sosp09"/>{{rp|p.2}} At the same time, the Haskell code defined an executable specification with which to reason, for automatic translation by the theorem-proving tool.<ref name="klein-sosp09"/>{{rp|p.3}} The Haskell code thus served as an intermediate prototype before final [[C (programming language)|C]] refinement.<ref name="klein-sosp09"/>{{rp|p.3}}
  −
 
  −
===Web===
  −
Haskell [[web framework]]s exist,<ref>{{cite web|url=http://www.haskell.org/haskellwiki/Web/Frameworks|title=Web/Frameworks|publisher=}}</ref> including:
  −
* [[Yesod (web framework)|Yesod]]
  −
* [[Snap (web framework)|Snap]]<ref>{{cite web|url=http://snapframework.com/ |title=Snap: A Haskell Web Framework: Home |publisher=Snapframework.com |accessdate=2013-06-26}}</ref>
  −
* [[Miso (web framework)|Miso]]
  −
 
  −
==Criticism==
  −
 
  −
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.<ref>Jan-Willem Maessen. ''Eager Haskell: Resource-bounded execution yields efficient iteration''. Proceedings of the 2002 [[Association for Computing Machinery]] (ACM) SIGPLAN workshop on Haskell.</ref><ref>Simon Peyton Jones. [http://research.microsoft.com/~simonpj/papers/haskell-retrospective ''Wearing the hair shirt: a retrospective on Haskell'']. Invited talk at [[POPL]] 2003.</ref> In addition to purely practical considerations such as improved performance,<ref>{{cite web|url=http://www.haskell.org/pipermail/haskell/2006-June/018127.html|title=Lazy evaluation can lead to excellent performance, such as in The Computer Language Benchmarks Game}}</ref> 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).
  −
 
  −
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."<ref>{{cite journal|first1=Bastiaan |last1=Heeren |first2=Daan |last2=Leijen |first3=Arjan |last3=van IJzendoorn|year=2003|title=Helium, for learning Haskell|journal=Proceedings of the 2003 [[Association for Computing Machinery|ACM]] [[SIGPLAN]] workshop on Haskell|url=http://www.cs.uu.nl/~bastiaan/heeren-helium.pdf}}</ref> To address these, researchers from Utrecht University developed an advanced interpreter called [[Helium (Haskell)|Helium]], which improved the user-friendliness of error messages by limiting the generality of some Haskell features, and in particular removing support for [[type class]]es.
  −
 
  −
Ben Lippmeier designed Disciple<ref>{{cite web|url=http://www.haskell.org/haskellwiki/DDC |title=DDC – HaskellWiki |publisher=Haskell.org |date=2010-12-03 |accessdate=2013-06-26}}</ref> as a [[evaluation strategy|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.<ref>Ben Lippmeier, [http://www.cse.unsw.edu.au/~benl/papers/thesis/lippmeier-impure-world.pdf Type Inference and Optimisation for an Impure World], [[Australian National University]] (2010) PhD thesis, chapter 1</ref>  He argues (p.&nbsp;20) that "destructive update furnishes the programmer with two important and powerful tools&nbsp;... 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."
  −
 
  −
[[Robert Harper (computer scientist)|Robert Harper]], one of the authors of [[Standard ML]], has given his reasons for not using Haskell to teach introductory programming. 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,<ref>{{cite web|url=http://existentialtype.wordpress.com/2011/04/24/the-real-point-of-laziness/|title=The point of laziness|author=Robert Harper}}
  −
</ref> and the "inferiority" of Haskell's (old) class system compared to ML's module system.<ref>{{cite web|url=http://existentialtype.wordpress.com/2011/04/16/modules-matter-most/|author=Robert Harper|title=Modules matter most.}}
  −
</ref>
  −
 
  −
It was consistently criticised  by developers due to the lack of good management of different versions of a particular library by default build tool, Cabal, in a [[dll hell]]. This has been addressed<ref>[https://www.haskell.org/communities/05-2017/report.pdf Haskell Communities and Activities Report, 32nd ed. May 2017, p. 17: Stack Build Tool, January 2015]</ref> by the release of the [[Stack (Haskell)|Stack]], which manages cabal, to do the work in a build.
  −
 
  −
Although Haskell has copious educational and conceptual type examples, frequently illustrated with the Integer and String types, their use is not the only way to program in Haskell; Integer type can be replaced, with Int or Word when performance is needed, and String type can be replaced with Text type to handle real-world situations more prudently.<ref>[ ''Real-World Haskell'' ]</ref>
  −
 
  −
==Related languages==
  −
[[Clean (programming language)|Clean]] is a close, slightly older relative of Haskell. Its biggest deviation from Haskell is in the use of [[uniqueness type]]s instead of monads for I/O and side-effects.
  −
 
  −
A series of languages inspired by Haskell, but with different type systems, have been developed, including:
  −
* [[Agda (theorem prover)|Agda]], a functional language with [[dependent type]]s
  −
* [[Idris (programming language)|Idris]], a general purpose functional language with [[dependent type]]s, developed at the [[University of St Andrews]]
  −
* [[Epigram (programming language)|Epigram]], a functional language with dependent types suitable for proving properties of programs
  −
* [[Cayenne (programming language)|Cayenne]], with [[dependent type]]s
  −
* [[Ωmega]], strict and more
  −
* [[Elm (programming language)|Elm]], a functional  language to create web front-end apps, no support for higher-kinded types
  −
 
  −
[[Java virtual machine]] (JVM) based:
  −
* [[Frege (programming language)|Frege]], a Haskell-like language with Java's [[Scalar (computing)|scalar]] types and good Java integration.<ref name="frege">{{cite web|url=http://fregepl.blogspot.com|title=Frege Programming Language|publisher=}}</ref><ref name="frege-wiki">{{cite web|url=http://code.google.com/p/frege/|title=Google Code Archive - Long-term storage for Google Code Project Hosting.|publisher=}}</ref><ref>{{cite web|url=http://mmhelloworld.blogspot.com.es/2012/02/hello-world-frege.html|title=mmhelloworld|author=Marimuthu Madasamy|publisher=}}</ref>
  −
* [[Jaskell]], a functional [[scripting language]] that runs in Java VM.<ref>{{cite web|url=http://jaskell.codehaus.org/|title=Codehaus|publisher=|deadurl=yes|archiveurl=https://web.archive.org/web/20060220023022/http://jaskell.codehaus.org/|archivedate=20 February 2006|df=dmy-all}}</ref>
  −
* Eta-lang, which intends to be Haskell on the JVM
  −
 
  −
Other related languages include:
  −
* [[Curry (programming language)|Curry]], a functional/logic programming language based on Haskell
  −
 
  −
Haskell has served as a testbed for many new ideas in language design. There have been many Haskell variants produced, exploring new language ideas, including:
  −
* Parallel Haskell:
  −
** From [[Glasgow University]], supports clusters of machines or single multiprocessors.<ref>{{cite web|url=http://www.macs.hw.ac.uk/~dsg/gph/|title=Glasgow Parallel Haskell|publisher=}}</ref><ref>{{cite web|url=http://www.haskell.org/ghc/docs/6.6/html/users_guide/lang-parallel.html|title=7.15.&nbsp;Parallel Haskell|publisher=}}</ref> Also within Haskell is support for Symmetric Multiprocessor parallelism.<ref>{{cite web|url=http://www.haskell.org/ghc/docs/6.6/html/users_guide/sec-using-smp.html|title=4.12.&nbsp;Using SMP parallelism|publisher=}}</ref>
  −
** From [[Massachusetts Institute of Technology|MIT]]<ref>{{cite web|url=http://csg.csail.mit.edu/projects/languages/ph.shtml|title=Computation Structures Group- MIT- LCS|author=Todd Allen Amicon|publisher=}}</ref>
  −
* Distributed Haskell (formerly Goffin) and Eden.{{Citation needed|date=April 2009}}
  −
* Eager Haskell, based on [[speculative execution|speculative evaluation]].
  −
* Several [[object-oriented programming|object-oriented]] versions: Haskell++, and Mondrian.
  −
* [[generic programming#Generic Haskell|Generic Haskell]], a version of Haskell with type system support for [[generic programming]].
  −
* O'Haskell, an extension of Haskell adding [[object-oriented programming|object-orientation]] and [[concurrent programming]] support that "has ... been superseded by [[Timber (programming language)|Timber]]".<ref>{{cite web|url=http://www.haskell.org/haskellwiki/O%27Haskell|title=O'Haskell|publisher=}}</ref>
  −
* Disciple, a strict-by-default (laziness available by annotation) dialect of Haskell that supports destructive update, computational effects, type directed field projections and allied functional aspects.
  −
* [[Hume (programming language)|Hume]], a strict functional language for [[embedded system]]s 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.
  −
 
  −
==Conferences and workshops==
  −
The Haskell community meets regularly for research and development activities. The main events are:
  −
* [[International Conference on Functional Programming]] (ICFP)
  −
* [[Haskell Symposium]] (formerly the Haskell Workshop)
  −
* Haskell Implementors Workshop
  −
* [[Commercial Users of Functional Programming]] (CUFP)
  −
 
  −
Since 2006, a series of organized ''hackathons'' has occurred, the Hac series, aimed at improving the programming language tools and libraries.<ref>{{cite web |title=Hackathon – HaskellWiki |url=http://haskell.org/haskellwiki/Hackathon}}</ref>
  −
 
  −
<!--per talk == Haskell Base library and algebra ==
  −
{{manual|date=September 2018|section}}
  −
{{primary sources|date=September 2018|section}}
  −
 
  −
As Haskell separates domains (types) and behaviour ([[type class]]es) you may find correspondences with the algebra world that underlies the standard typeclasses of the Haskell basic library.
  −
 
  −
The ''Num'' class has the operation signatures required for a [[Ring (mathematics)|Ring]], except for the (+) and (*) neutral elements, which are predefined as literals.<ref>[http://hackage.haskell.org/package/base/docs/Prelude.html#t:Num The Num type class]</ref>
  −
 
  −
Operation laws like (+) and (*) associativity and addition commutativity are not related with the typeclass, but rather proofs to be checked on the instances.
  −
  −
<source lang="haskell">
  −
$ ghci
  −
Prelude> :type 0
  −
0 :: Num a => a        -- 0 belongs to any type that has a Num instance, a Ring
  −
Prelude> :type 1
  −
1 :: Num a => a        -- neutral for the product of a type that implements Num
  −
</source>
  −
 
  −
The ''Word'' data types (Word, WordN) implement the ''Num'' type class with [[modular arithmetic]] whereas the data types Int and IntN use [[two's complement]] [[arithmetic]] that does not match the [[decimal arithmetic]] (see [[Integer overflow]]):{{discuss}}
  −
 
  −
<source lang="haskell">
  −
Prelude> (signum maxBound ::Int) == signum (maxBound +1)   
  −
False -- ??? maxBound successor doesn't obey arithmetic rule  (it doesn't throw exceptions)
  −
 
  −
Prelude> (signum maxBound ::Int) == signum (maxBound *2)   
  −
False -- ??? Int product overflow (no exceptions either)
  −
 
  −
Prelude> (-minBound ::Int) /= minBound  -- where Int minBound == sign bit set followed by zeros
  −
False  -- ??? Negate overflow
  −
</source>
  −
Possible workarounds to make it match with regular [[arithmetic]], throwing an exception on overflow, are
  −
* to check the addition result for same ''signum'' {-1,0,1} with the operands when operand signs match;<ref>[http://hackage.haskell.org/package/base/docs/Prelude.html#v:signum Num typeclass ''signum'' function]</ref><ref name="safe-int-addition">[https://www.schoolofhaskell.com/user/griba/safe_int_addition_and_product SchoolOfHaskell.com - Safe Int addition and product]</ref> or
  −
* to perform the operation with unlimited precision, checking the typecasted result.<ref name="safe-int-addition"/>
  −
 
  −
The ''Fractional'' type class adds to Num the [[multiplicative inverse]] in the ''recip'' function (for "reciprocal") and, as a consequence, the [[Division (mathematics)|division]]. It corresponds to a [[Field (mathematics)|Field]].<ref>[http://hackage.haskell.org/package/base/docs/Prelude.html#t:Fractional The Fractional type class]</ref>
  −
 
  −
The ''Real'' type class requires Num and Ord, corresponds to an [[Ordered ring]],<ref>[http://hackage.haskell.org/package/base/docs/Prelude.html#t:Real The Real type class]</ref> which serves to [[Integer number]]s, [[Rational number|Rational]]<ref>[http://hackage.haskell.org/package/base/docs/Data-Ratio.html The Rational numbers module]</ref> and [[Floating point]] numbers.<ref name="prelude-float">[http://hackage.haskell.org/package/base/docs/Prelude.html#t:Float The Float data type]</ref>
  −
 
  −
The ''Integral'' type class adds operations for [[Euclidean division]] to the required ''Real'' and ''Enum'' classes, corresponding to a [[Euclidean ring]], which is an [[integral ring]].<ref>[http://hackage.haskell.org/package/base/docs/Prelude.html#t:Integral The Integral type class]</ref>
  −
 
  −
The ''Floating'' type class adds to ''Fractional'' the [[calculus]] functions (''sqrt'', [[trigonometric functions]], [[logarithm]]s) common to [[floating point]] (Float, Double) and [[Complex number|complex]] numbers.<ref name="prelude-floating">[http://hackage.haskell.org/package/base/docs/Prelude.html#t:Floating The Floating type class]</ref><ref name="prelude-float"/><ref>[http://hackage.haskell.org/package/base/docs/Data-Complex.html#t:Complex The Complex data type]</ref>
  −
 
  −
[[Exponentiation]] comes in three flavours:
  −
 
  −
{{unordered list
  −
| A positive integer exponent requires that the base domain has the product (specified in ''Num'', signature of a [[Ring (mathematics)|ring]]):
  −
<source lang="haskell">
  −
(^) :: (Num a, Integral ex) => a -> ex -> a    -- (^) admits non-negative exponents of an euclidean domain, throws an error if the exponent is negative
  −
</source>
  −
| A negative integer exponent requires that the base domain has the [[multiplicative inverse]] (specified in ''Fractional'', signature of a [[Field (mathematics)|field]]):
  −
<source lang="haskell">
  −
(^^) :: (Fractional a, Integral ex) => a -> ex -> a  -- (^^) admits all exponents of an euclidean domain
  −
</source>
  −
| A [[floating point]] exponent requires that the base domain has the floating point [[exponentiation]] and [[logarithm]] functions, as specified in the ''Floating'' type class:<ref name="prelude-floating"/>
  −
<source lang="haskell">
  −
(**) :: (Floating a, Floating ex) => a -> ex -> a
  −
</source>}}
  −
 
  −
Conversions between Euclidean types preserve the representation, not the value. Numeric type downcasting does not throw an overflow exception:
  −
<source lang="haskell">
  −
$ ghci
  −
Prelude> import Data.Int
  −
Prelude Data.Int> fromIntegral (32767 :: Int16) :: Int8
  −
-1
  −
Prelude Data.Int> fromInteger (2^64 :: Integer) :: Int32
  −
0
  −
</source>
  −
per talk -->
  −
 
  −
==References==
  −
{{Reflist|30em}}
  −
 
  −
==Further reading==
  −
; Reports
  −
* {{cite book| editor-first = Simon| editor-last = Peyton Jones| editor-link = Simon Peyton Jones| title = Haskell 98 Language and Libraries: The Revised Report| url = http://haskell.org/onlinereport/| year = 2003| publisher = Cambridge University Press| isbn = 0521826144| ref = harv}}
  −
* {{cite book| editor-first = Simon| editor-last = Marlow| editor-link = Simon Marlow| title = Haskell 2010 Language Report| url= https://www.haskell.org/definition/haskell2010.pdf| year = 2010| publisher = Haskell.org | ref = harv}}
  −
; Textbooks
  −
*{{cite book|first=Antony|last=Davie|title=An Introduction to Functional Programming Systems Using Haskell|publisher=Cambridge University Press|year=1992|isbn=0-521-25830-8}}
  −
*{{cite book|first=Richard|last=Bird|authorlink=Richard Bird (computer scientist)|title=Introduction to Functional Programming using Haskell|edition=2nd|publisher=Prentice Hall Press|year=1998|isbn=0-13-484346-0|url=http://www.cs.ox.ac.uk/publications/books/functional/}}
  −
*{{cite book|first=Paul|last=Hudak|authorlink=Paul Hudak|title=The Haskell School of Expression: Learning Functional Programming through Multimedia|publisher=Cambridge University Press|location=New York|year=2000|isbn=0521643384|url=http://www.cs.yale.edu/homes/hudak/SOE/}}
  −
*{{cite book|first=Graham|last=Hutton|authorlink=Graham Hutton|title=Programming in Haskell|year=2007|publisher=Cambridge University Press|isbn=0521692695|url=http://www.cs.nott.ac.uk/~gmh/book.html}}
  −
*{{Cite book|first1=Bryan|last1=O'Sullivan|authorlink1=Bryan O'Sullivan (computer programmer)|first2=Don|last2=Stewart|authorlink2=Don Stewart (computer programmer)|last3=Goerzen|first3=John|authorlink3=John Goerzen|title=[[Real World Haskell]]|year=2008|publisher=O'Reilly|location=Sebastopol|isbn=0-596-51498-0|postscript=&nbsp;([http://book.realworldhaskell.org/read/ full text])}}
  −
*{{cite book|first=Simon|last=Thompson|title=Haskell: The Craft of Functional Programming|edition=3rd|publisher=Addison-Wesley|year=2011|isbn=0201882957|url=http://www.haskellcraft.com/}}
  −
*{{cite book|last=Lipovača|first=Miran |title=Learn You a Haskell for Great Good!|url=http://learnyouahaskell.com/|date=April 2011|publisher=No Starch Press|location=San Francisco|isbn=978-1-59327-283-8}} ([http://learnyouahaskell.com/chapters full text])
  −
*{{cite book|first=Richard|last=Bird|authorlink=Richard Bird (computer scientist)|title=Thinking Functionally with Haskell |publisher=Cambridge University Press|year=2014|isbn= 978-1-107-45264-0}}
  −
; Tutorials
  −
*{{cite web|url=http://haskell.org/tutorial/|title=A Gentle Introduction To Haskell, Version 98|date=June 2000|first1=Paul |last1=Hudak |first2=John |last2=Peterson |first3=Joseph |last3=Fasel|work=Haskell.org}}
  −
*[http://hal3.name/docs/daume02yaht.pdf Yet Another Haskell Tutorial], by Hal Daumé III; assumes far less prior knowledge than official tutorial
  −
*{{Cite journal|last=Yorgey|first=Brent|date=12 March 2009|title=The Typeclassopedia|journal=The Monad.Reader|issue=13|pages=17–68|url=http://www.haskell.org/wikiupload/8/85/TMR-Issue13.pdf|postscript=<!-- Bot inserted parameter. Either remove it; or change its value to "." for the cite to end in a ".", as needed. -->{{inconsistent citations}}}}
  −
; History
  −
* {{cite journal| first1 = Paul| last1 = Hudak| authorlink1 = Paul Hudak| first2 = John| last2 = Hughes| authorlink2 = John Hughes (computer scientist)| first3 = Simon| last3 = Peyton Jones| authorlink3 = Simon Peyton Jones| first4 = Philip| last4 = Wadler| authorlink4 = Philip Wadler| title = A History of Haskell: Being Lazy with Class| url = http://research.microsoft.com/~simonpj/papers/history-of-haskell/history.pdf | doi = 10.1145/1238844.1238856| year = 2007| journal = Proceedings of the third ACM [[SIGPLAN]] conference on History of programming languages ([[HOPL]] III)| pages = 12-1–55| isbn = 978-1-59593-766-7|ref=harv}}
  −
* {{cite journal|last=Hamilton|first=Naomi|date=19 September 2008|title=The A-Z of Programming Languages: Haskell|journal=[[Computerworld]]|url=http://www.computerworld.com.au/article/261007/a-z_programming_languages_haskell/}}
  −
 
  −
==External links==
  −
{{Wikibooks|Haskell}}
  −
{{Wikibooks|Write Yourself a Scheme in 48 Hours}}
  −
*{{Official website}}
  −
*[https://wiki.haskell.org/ Haskell Wiki]
  −
*[https://planet.haskell.org/ Planet Haskell] an aggregator of Haskell related blogs and other Haskell-related news sites
  −
*[http://hackage.haskell.org/ Hackage] – central package archive
  −
*[https://www.haskell.org/hoogle/ Hoogle] – API search engine
  −
*[http://tryhaskell.org/ Try Haskell!] – in-browser interactive tutorial
  −
*[https://www.fpcomplete.com/school School of Haskell] – online tutorials
  −
*[http://adit.io/posts/2013-04-17-functors,_applicatives,_and_monads_in_pictures.html Functors, Applicatives, And Monads In Pictures]
  −
*[http://book.realworldhaskell.org/read/ Real World Haskell] - free to read online
  −
*[http://www.willamette.edu/~fruehr/haskell/evolution.html The Evolution of a Haskell Programmer] – slightly humorous overview of different programming styles in Haskell
  −
 
  −
{{Authority control}}
  −
 
  −
{{use dmy dates|date=March 2012}}
  −
 
  −
{{Programming languages}}
  −
 
  −
[[Category:Academic programming languages]]
  −
[[Category:Articles with example Haskell code]]
  −
[[Category:Educational programming languages]]
  −
[[Category:Functional languages]]
  −
[[Category:Haskell programming language family| ]]
  −
[[Category:Literate programming]]
  −
[[Category:Pattern matching programming languages]]
  −
[[Category:Programming languages created in 1990]]
  −
[[Category:Statically typed programming languages]]
 
Block, SkipCaptcha, Automoderated users, edit, rollback
1,464

edits

Navigation menu