Personal tools

Example code

From HaskellWiki

(Difference between revisions)
Jump to: navigation, search
m (Replaced the link for the state doc with a better one)
Line 24: Line 24:
 
* [http://www.cse.unsw.edu.au/~dons/data/QuickCheck.html QuickCheck.hs], a testing framework ([http://darcs.haskell.org/packages/QuickCheck/Test/QuickCheck.hs raw], [http://haskell.org/ghc/docs/latest/html/libraries/QuickCheck/Test-QuickCheck.html docs])
 
* [http://www.cse.unsw.edu.au/~dons/data/QuickCheck.html QuickCheck.hs], a testing framework ([http://darcs.haskell.org/packages/QuickCheck/Test/QuickCheck.hs raw], [http://haskell.org/ghc/docs/latest/html/libraries/QuickCheck/Test-QuickCheck.html docs])
 
* [http://www.cse.unsw.edu.au/~dons/data/HughesPJ.html PrettyPrint.hs], a pretty printing library ([http://darcs.haskell.org/packages/base/Text/PrettyPrint/HughesPJ.hs raw], [http://haskell.org/ghc/docs/latest/html/libraries/base/Text-PrettyPrint-HughesPJ.html docs])
 
* [http://www.cse.unsw.edu.au/~dons/data/HughesPJ.html PrettyPrint.hs], a pretty printing library ([http://darcs.haskell.org/packages/base/Text/PrettyPrint/HughesPJ.hs raw], [http://haskell.org/ghc/docs/latest/html/libraries/base/Text-PrettyPrint-HughesPJ.html docs])
* [http://www.cse.unsw.edu.au/~dons/data/State.html State.hs], a state monad ([http://darcs.haskell.org/packages/mtl/Control/Monad/State.hs raw], [http://haskell.org/ghc/docs/latest/html/libraries/mtl/Control-Monad-State.html docs])
+
* [http://www.cse.unsw.edu.au/~dons/data/State.html State.hs], a state monad ([http://darcs.haskell.org/packages/mtl/Control/Monad/State.hs raw], [http://haskell.org/ghc/docs/latest/html/libraries/mtl/Control-Monad-State-Lazy.html docs])
 
* [http://www.cse.unsw.edu.au/~dons/data/Music.html Music.hs], a music composition system (literate latex-style Haskell) ([http://darcs.haskell.org/haskore/src/Haskore/Music.lhs raw], [http://haskell.org/haskore/ home])
 
* [http://www.cse.unsw.edu.au/~dons/data/Music.html Music.hs], a music composition system (literate latex-style Haskell) ([http://darcs.haskell.org/haskore/src/Haskore/Music.lhs raw], [http://haskell.org/haskore/ home])
 
* [http://www.ninebynine.org/Software/Swish-0.2.1/HaskellRDF/Dfa/Dfa.lhs Dfa.lhs], finite automata (literate Bird-style Haskell)
 
* [http://www.ninebynine.org/Software/Swish-0.2.1/HaskellRDF/Dfa/Dfa.lhs Dfa.lhs], finite automata (literate Bird-style Haskell)

Revision as of 14:06, 20 July 2007

To get a feel for what real world Haskell looks like, here are some examples from various popular Haskell projects. To start learning the language, good places to start are here, here and here.

More code may be found on the wiki.


1 Library code

Library code usually differs from application code: it is often highly structured, and documented with haddock, and can be rather optimised. Some instructive examples (syntax highlighting by hscolour):

2 Application code

Code from popular Haskell applications. Such code often makes use of a monadic IO, and sometimes other advanced features such as concurrency:

3 Examples

Tying the Knot 
An example that illustrates different ways to define recursive data structures. The example defines a simple language (illustrating how to define some recursive structures) and an interpreter for the language (illustrating how to work with the recursive structures).