Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
1Activity
0 of .
Results for:
No results containing your search query
P. 1
daume02yaht

daume02yaht

Ratings: (0)|Views: 4|Likes:
Published by api-3835322

More info:

Published by: api-3835322 on Oct 18, 2008
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

03/18/2014

pdf

text

original

Yet Another Haskell Tutorial
Hal Daum\u00b4
e III

Copyright (c) Hal Daume III, 2002-2006. The preprint version of this tutorial is intended to be free to the entire Haskell community, so we grant permission to copy and distribute it for any purpose, provided that it is reproduced in its entirety, in- cluding this notice. Modi\ufb01ed versions may not be distributed without prior concent of the author, and must still maintain a copy of this notice. The author retains the right to change or modify this copyright at any time, as well as to make the book no longer free of charge.

About This Report

The goal of theYet Another Haskell Tutorial is to provide a complete intoduction to the Haskell programming language. It assumes no knowledge of the Haskell language or familiarity with functional programming in general. However, general familiarity with programming concepts (such as algorithms) will be helpful. This is not intended to be an introduction to programming in general; rather, to programming in Haskell. Suf\ufb01cient familiarity with your operating system and a text editor is also necessary (this report only discusses installation on con\ufb01guration on Windows and *Nix system; other operating systems may be supported \u2013 consult the documentation of your chosen compiler for more information on installing on other platforms).

What is Haskell?

Haskell is called a lazy, pure functional programming language. It is calledlazy be- cause expressions which are not needed to determine the answer to a problem are not evaluated. The opposize of lazy isstrict, which is the evaluation strategry of most common programming languages (C, C++, Java, even ML). A strict language is one in which every expression is evaluated, whether the result of its computation is important or not. (This is probably not entirely true as optimizing compilers for strict languages often do what\u2019s called \u201cdead code elmination\u201d \u2013 this removes unused expressions from the program.) It is calledpure because it does not allow side effects (A side effect is something that affects the \u201cstate\u201d of the world. For instance, a function that prints something to the screen is said to be side-effecting, as is a function which affects the value of a global variable.) \u2013 of course, a programming language without side effects would be horribly useless; Haskell uses a system ofmonads to isolate all impure com- putations from the rest of the program and perform them in the safe way (see Chapter 9 for a discussion of monads proper or Chapter 5 for how to do input/output in a pure language).

Haskell is called afunctional language because the evaluation of a program is equivalent to evaluating a function in the pure mathematical sense. This also differs from standard languages (like C and Java) which evaluate a sequence of statements, one after the other (this is termed animperative langauge).

i
ii
The History of Haskell
The history of Haskell is best described using the words of the authors. The following
text is quoted from the published version of the Haskell 98 Report:

In September of 1987 a meeting was held at the conference on Functional Programming Languages and Computer Architecture (FPCA \u201987) in Port- land, Oregon, to discuss an unfortunate situation in the functional pro- gramming community: there had come into being more than a dozen non- strict, purely functional programming languages, all similar in expressive power and semantic underpinnings. There was a strong consensus at this meeting that more widespread use of this class of functional languages was being hampered by the lack of a common language. It was decided that a committee should be formed to design such a language, providing faster communication of new ideas, a stable foundation for real applications de- velopment, and a vehicle through which others would be encouraged to use functional languages. This document describes the result of that com- mittee\u2019s efforts: a purely functional programming language called Haskell, named after the logician Haskell B. Curry whose work provides the logical basis for much of ours.

The committee\u2019s primary goal was to design a language that satis\ufb01ed these
constraints:
1. It should be suitable for teaching, research, and applications, includ-
ing building large systems.
2. It should be completely described via the publication of a formal
syntax and semantics.
3. It should be freely available. Anyone should be permitted to imple-
ment the language and distribute it to whomever they please.
4. It should be based on ideas that enjoy a wide consensus.
5. It should reduce unnecessary diversity in functional programming
languages.

The committee intended that Haskell would serve as a basis for future research in language design, and hoped that extensions or variants of the language would appear, incorporating experimental features.

Haskell has indeed evolved continuously since its original publication. By the middle of 1997, there had been four iterations of the language design (the latest at that point being Haskell 1.4). At the 1997 Haskell Workshop in Amsterdam, it was decided that a stable variant of Haskell was needed; this stable language is the subject of this Report, and is called \u201cHaskell 98\u201d.

Haskell 98 was conceived as a relatively minor tidy-up of Haskell 1.4,
making some simpli\ufb01cations, and removing some pitfalls for the unwary.

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->