Haskell (programming language)

nichecreator.com

diet pills

Popular Searches

tracy turner
jennifer aniston calendar
west memphis three
21st amendment
dog saves dog
marshmallow popper
kent clapp
vicdays.com
facebook virus
plenio vxa 2100
repeal day
turner fashion enterprises
price spider
cheerleaders booted after naked pix
paul benedict
constitution arms
times union
roy orbison songs
barbara walters most fascinating people
fox and friends
doreen giuliano
sharon little
oj simpson sentencing
syracuse retirement
green chimneys
aaron jay lemon
koobface
america at home
john giuca
repeal of prohibition
slacker radio
koobface virus
02138
steve branch
animecrazy
st. nicholas day
barbara walters top 10
terry hobbs
joe satriani if i could fly
lisa glide
harry winston
obama birth certificate supreme court
seth macfarlane
audun carlsen
mirabile dictu
price fighter
beth riesgraf
vic days
marc dreier
army navy game
intel journey inside
timesunion.com
cadillac records
obama natural born citizen
unemployment report
proposal rock
one guy one cup
december 5
koobface removal
rutgers football
o.j. simpson
foxandfriends.com
doug reinhardt
sneaker wave
dreier llp
palm pistol
de anza
nicole brown simpson
islam is the light doll
rampage
end of prohibition
newfoundland
winepod
johnny mathis
idea village marshmallow popper
motor city bowl
valley forge convention center
sydney simpson
angel food ministries
angela honeycutt
charles rogers
the jeffersons
steve dahl
party arty
straight no chaser
icelebpics
wallpass.net
damien echols
medical mutual
skittish
sexting
dmca
mistress jade vixen
battle of bunker hill
mj morning show
salvation army wiki
peter limone
nebraska dmv
who warned nbc thursday about the centipede market
trail mix

Haskell
Image:Haskell Logo.jpg
Paradigm functional, non-strict, modular
Appeared in 1990
Designed by Simon Peyton-Jones, Paul Hudak[1], Philip Wadler, et al.
Typing discipline static, strong, inferred
Major implementations GHC, Hugs, NHC, JHC, Yhc
Dialects Helium, Gofer
Influenced Bluespec, C#, CAL, Cat, Cayenne, Clean, Curry, Epigram, Escher, F#, Factor, Isabelle, Java Generics, LINQ, Mercury, Perl 6, Python, Scala
Website http://haskell.org/

Haskell is a standardized purely functional programming language with non-strict semantics, named after the logician Haskell Curry. The goals of the language are described as:[2]

"Haskell is an advanced purely functional programming language. An open source product of more than twenty years of cutting edge research, it allows rapid development of robust, concise, correct software. With strong support for integration with other languages, built-in concurrency and parallelism, debuggers, profilers, rich libraries and an active community, Haskell makes it easier to produce flexible, maintainable high-quality software."

Contents

History

Following the release of Miranda by Research Software Ltd, in 1985, interest in lazy functional languages proliferated. By 1987, more than a dozen non-strict, purely functional programming languages existed. Of these Miranda was the most widely used, but was not in the public domain. At the conference on Functional Programming Languages and Computer Architecture (FPCA '87) in Portland, Oregon, a meeting was held during which strong consensus was found among the participants that a committee should be formed to define an open standard for such languages. This would have the express purpose of consolidating the existing languages into a common one that would serve as a basis for future research in language design.[3] The first version of Haskell ("Haskell 1.0") was defined in 1990.[4] The committee's efforts resulted in a series of language definitions, which in late 1997, 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. The committee expressly welcomed the creation of extensions and variants of Haskell 98 via adding and incorporating experimental features.

In January 1999, the Haskell 98 language standard was originally published as "The Haskell 98 Report". In January 2003, a revised version was published as "Haskell 98 Language and Libraries: The Revised Report".[5] The language continues to evolve rapidly, with the Hugs and GHC implementation (see below) representing the current de facto standard. In early 2006, the process of defining a successor to the Haskell 98 standard, informally named Haskell′ ("Haskell Prime"), was begun.[6] This process is intended to produce a minor revision of Haskell 98.[7]

Features and extensions

Characteristic features of Haskell include pattern matching, currying, list comprehensions [8], guards, definable operators, and single assignment. The language also supports recursive functions and algebraic data types, as well as lazy evaluation. Unique concepts include monads, and type classes. The combination of such features can make functions which would be difficult to write in a procedural programming language almost trivial to implement in Haskell.[citation needed]

Several variants have been developed: parallelizable versions from MIT and Glasgow University, both called Parallel Haskell; more parallel and distributed versions called Distributed Haskell (formerly Goffin) and Eden; a speculatively evaluating version called Eager Haskell and several object oriented versions: Haskell++, O'Haskell and Mondrian.

Concurrent Clean is a close relative of Haskell, whose biggest deviation from Haskell is in the use of uniqueness types for input instead of monads.

Applications

Haskell's strengths have been well applied to a few projects. It is increasingly being used in commercial situations[9]. Audrey Tang's Pugs is an implementation for the long-forthcoming Perl 6 language with an interpreter and compilers that proved useful already after just a few months of its writing; similarly, GHC is often a testbed for advanced functional programming features and optimizations. Darcs is a revision control system, with several innovative features. Linspire GNU/Linux chose Haskell for system tools development.[10] Xmonad is a window manager for the X Window System, written entirely in Haskell. Bluespec SystemVerilog is a language for semiconductor design that is an extension of Haskell. Additionally, Bluespec, Inc.'s tools are implemented in Haskell.

Examples

A simple example that is often used to demonstrate the syntax of functional languages is the factorial function for non-negative integers, shown in Haskell:

factorial :: Integer -> Integer
factorial 0 = 1
factorial n | n > 0 = n * factorial (n-1)

Or in one line:

factorial n = if n > 0 then n * factorial (n-1) else 1

This describes the factorial as a recursive function, with one terminating base case. It is similar to the descriptions of factorials found in mathematics textbooks. Much of Haskell code is similar to standard mathematical notation in facility and syntax.

The first line of the factorial function describes the types of this function; while it is optional, it is considered to be good style[11] to include it. It can be read as the function factorial (factorial) has type (::) from integer to integer (Integer -> Integer). That is, it takes an integer as an argument, and returns another integer. The type of a definition is inferred automatically if the programmer didn't supply a type annotation.

The second line relies on pattern matching, an important feature of Haskell. Note that parameters of a function are not in parentheses but separated by spaces. When the function's argument is 0 (zero) it will return the integer 1 (one). For all other cases the third line is tried. This is the recursion, and executes the function again until the base case is reached.

A guard protects the third line from negative numbers for which a factorial is undefined. Without the guard this function would recurse through all negative numbers without ever reaching the base case of 0. As it is, the pattern matching is not complete: if a negative integer is passed to the fac function as an argument, the program will fail with a runtime error. A final case could check for this error condition and print an appropriate error message instead.

The "Prelude" is a number of small functions analogous to C's standard library. Using the Prelude and writing in the point-free style[12] of unspecified arguments, it becomes:

fac = product . enumFromTo 1

The above is close to mathematical definitions such as f = g \circ h (see function composition) with the dot acting as the function composition operator, and indeed, it is not an assignment of a numeric value to a variable.

In the Hugs interpreter, you often need to define the function and use it on the same line separated by a where or let..in, meaning you need to enter this to test the above examples and see the output 120:

let { fac 0 = 1; fac n | n > 0 = n * fac (n-1) } in fac 5

or

fac 5 where fac = product . enumFromTo 1

The GHCi interpreter doesn't have this restriction and function definitions can be entered on one line and referenced later.

More complex examples

A simple Reverse Polish Notation calculator expressed with the higher-order function foldl whose argument f is defined in a where clause using pattern matching and the type class Read:

calc :: String -> [Float]
calc = foldl f [] . words
  where 
    f (x:y:zs) "+" = y+x:zs
    f (x:y:zs) "-" = y-x:zs
    f (x:y:zs) "*" = y*x:zs
    f (x:y:zs) "/" = y/x:zs
    f xs y = read y : xs

The empty list is the initial state, and f interprets one word at a time, either matching two numbers from the head of the list and pushing the result back in, or parsing the word as a floating-point number and prepending it to the list.

The following definition produces the list of Fibonacci numbers in linear time:

fibs = 0 : 1 : zipWith (+) fibs (tail fibs)

The infinite list is produced by corecursion — the latter values of the list are computed on demand starting from the initial two items 0 and 1. This kind of a definition relies on lazy evaluation, an important feature of Haskell programming. For an example of how the evaluation evolves, the following illustrates the values of fibs and tail fibs after the computation of six items and shows how zipWith (+) has produced four items and proceeds to produce the next item:

fibs         = 0 : 1 : 1 : 2 : 3 : 5 : ...
               +   +   +   +   +   +
tail fibs    = 1 : 1 : 2 : 3 : 5 : ...
               =   =   =   =   =   =
zipWith ...  = 1 : 2 : 3 : 5 : 8 : ...
fibs = 0 : 1 : 1 : 2 : 3 : 5 : 8 : ...

The same function, written using GHC's parallel list comprehension syntax (GHC extensions must be enabled using a special command-line flag '-fglasgow-exts'; see GHC's manual for more):

fibs = 0 : 1 : [ a+b | a <- fibs | b <- tail fibs ]

The factorial we saw previously can be written as a sequence of functions:

fac n = (foldl (.) id [\x -> x*k | k <- [1..n]]) 1

A remarkably concise function that returns the list of Hamming numbers in order:

hamming = 1 : map (2*) hamming `merge` map (3*) hamming `merge` map (5*) hamming
     where merge (x:xs) (y:ys) 
            | x < y = x : xs `merge` (y:ys)
            | x > y = y : (x:xs) `merge` ys
            | otherwise = x : xs `merge` ys

Like the various fibs solutions displayed above, this uses corecursion to produce a list of numbers on demand, starting from the base case of 1 and building new items based on the preceding part of the list.

In this case the producer merge is defined in a where clause and used as an operator by enclosing it in back-quotes. The branches of the guards define how merge merges two ascending lists into one ascending list without duplicate items.

See also wikibooks:Transwiki:List of hello world programs#Haskell for an example that prints text.

Criticism

Jan-Willem Maessen, in 2002, and Simon Peyton Jones, in 2003, discussed problems associated with lazy evaluation while also acknowledging the theoretical motivation for it[13][14], in addition to purely practical considerations such as improved performance.[15] They note that, in addition to adding some performance overhead, laziness makes it more difficult for programmers to reason about the performance of their code (specifically with regard to memory usage).

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."[16] To address these, they 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.

Implementations

The following all comply fully, or very nearly, with the Haskell 98 standard, and are distributed under open source licenses. There are currently no proprietary Haskell implementations.

Libraries

Since January 2007, libraries and applications written in Haskell have been collected on "Hackage", an online database of open source Haskell software using Cabal packaging tool. By November 2008 there were some 850 packages available.

Hackage provides a central point for the distribution of Haskell software, via Cabal, and has become a hub for new Haskell development activity. Installing new Haskell software via Hackage is possible via the cabal-install tool:

   $ cabal install xmonad

which recursively installs required dependencies if they are available on Hackage. This makes installation of Haskell code easier than had been possible previously.

See also

References

  1. ^ Professor Paul Hudak's Home Page
  2. ^ "Haskell.org".
  3. ^ "Preface". Haskell 98 Language and Libraries: The Revised Report (December 2002).
  4. ^ "The History of Haskell".
  5. ^ Simon Peyton Jones (editor) (December 2002). "Haskell 98 Language and Libraries: The Revised Report".
  6. ^ "Future development of Haskell".
  7. ^ "Welcome to Haskell'". The Haskell' Wiki.
  8. ^ list comprehension has been adopted by Python (programming language)
  9. ^ "Haskell in Industry".
  10. ^ "Linspire/Freespire Core OS Team and Haskell". Debian Haskell mailing list (May 2006).
  11. ^ HaskellWiki: Type signatures as good style
  12. ^ HaskellWiki: Pointfree
  13. ^ Jan-Willem Maessen. Eager Haskell: Resource-bounded execution yields efficient iteration. Proceedings of the 2002 ACM SIGPLAN workshop on Haskell.
  14. ^ Simon Peyton Jones. Wearing the hair shirt: a retrospective on Haskell. Invited talk at POPL 2003.
  15. ^ Lazy evaluation can lead to excellent performance, such as in The Computer Language Benchmarks Game[1]
  16. ^ Bastiaan Heeren, Daan Leijen, Arjan van IJzendoorn. Helium, for learning Haskell. Proceedings of the 2003 ACM SIGPLAN workshop on Haskell.

External links

Tutorials

Retrieved from "http://en.wikipedia.org/wiki/Haskell_(programming_language)"



Haskell Witch Burning (Panáček Haskelláček na hranici)

There's a time in every theoretical computer scientist's life when he has to face his or hers ultimate arch-enemy: Haskell, the evil programming "language". We've all been there. We know what it's like. We know how awful the stench of it's paradigm is. So it's only natural to burn a witch or two and pretend it's actually Haskell being burned. In this setup the witch is set on a small phosphorus charge which was supposed to set it all on fire, but it just kinda didn't. In the end the fire is put out by a pot with eerily glowing green...ish goo, which represents Haskell's documentation (and my lunch).

Author: chorioretinitis
Keywords: haskell witch burning
Added: November 26, 2008


PRINTF #22 Printf Documentation

PRINTF documentation[[iostream]] and [[iomanip]]) *[[F Sharp (programming language)]] *[[GNU Octave]] *[[Haskell programming language|Haskell]] *[[Java (programming language)|Java programming language]] (since version 1.5) *[[Maple]] *[[Mathematica]] *[[MATLAB]] *[[Objective Caml]] *[[PHP]] programming language, web-based inflected form of C *[[Python (programming language)|Python programming language]] (using the % operator) *[[Perl]] *[[Ruby (programming language)|Ruby programming language]] ==See also== * *[[C standard library]]*[[Format string attack]] * ==External links== *[http://www.pixelbeat.org/programming/gcc/format_specs.html printf format specifications quick reference] *{{man|sh|printf|SUS|print formatted output}} *The [http://java.sun.com/j2se/1.5.0/docs/api/java/util/Formatter.html#syntax

Author: h4ck3rm1k3
Keywords: GNU GPL OPEN SOURCE Linux Journal computer science programming C-language unix ansi standard learning tutorial Wikipedia
Added: November 12, 2008


Frag - 3D FPS game written in Haskell

Frag is a 3D first person shooting game written in the Haskell programming language (not written by me). It looks a bit jerky because of the capturing software i'm using but look closely at the framerate counter. I will write how to make a build yourself later. EDIT: so i've written a blog and on how to build, install and run frag the easy way: http://monadickid.blogspot.com/2008/11/haskell-eye-for-windows-guy.html

Author: OriginalSnkKid
Keywords: haskell opengl functional programming game dev
Added: November 9, 2008


GCCS97 #696 Proceedings of the GCC Developers Summit 2007

From http://ols.108.redhat.com/2007/GCC-Reprints/GCC2007-Proceedings.pdf . copying collectors,17 detailed below. Hence, a copying generational garbage collector has been implemented for our abstract interpreters. It is copying generational for young data, but mark and sweep for old data. It works by allocating (with a quick current pointer incrementation) inside a birth zone (typically 4Mwords), without any additional space overhead. 15 It would be very difficult for the developer of an abstract interpreter to know when to free an abstract value. 16 Thru the G.T.Y marker used by the gengtype generator. 17 Like in most efficient implementations of functional programming languages—Ocaml, Haskell, . . . the number of local pointers

Author: h4ck3rm1k3
Keywords: Free Software GNU FSF GCC Developers Summit GCCS97
Added: October 19, 2008


Erik Meijer JAOO 2

Erik's hilarious and excellent keynote about fundamentalist functional programming: I finally understand what monads are about!

Author: chanezon
Keywords: haskell functional software language monads jaoo 2008
Added: October 1, 2008



© 2008 nichecreator.com

diet pills