Personal tools

Example code

From HaskellWiki

(Difference between revisions)
Jump to: navigation, search
(some links)
(colorised source)
Line 10: Line 10:
 
and can be rather optimised. Some instructive examples:
 
and can be rather optimised. Some instructive examples:
   
* [http://www.cse.unsw.edu.au/~dons/data/Prelude.hs A Haskell98 Prelude.hs], foundational Haskell library
+
* [http://www.cse.unsw.edu.au/~dons/data/Prelude.html A Haskell98 Prelude.hs], foundational Haskell library ([http://www.cse.unsw.edu.au/~dons/data/Prelude.hs raw])
* [http://www.cse.unsw.edu.au/~dons/data/List.hs List.hs], the standard list library
+
* [http://www.cse.unsw.edu.au/~dons/data/List.html List.hs], the standard list library ([http://www.cse.unsw.edu.au/~dons/data/List.hs raw])
* [http://www.cse.unsw.edu.au/~dons/data/Maybe.hs Maybe.hs], the <code>Maybe</code> type
+
* [http://www.cse.unsw.edu.au/~dons/data/Maybe.html Maybe.hs], the <code>Maybe</code> type ([http://www.cse.unsw.edu.au/~dons/data/Maybe.hs raw])
 
* [http://darcs.haskell.org/packages/base/Data/Map.hs Map.hs], the standard finite map
 
* [http://darcs.haskell.org/packages/base/Data/Map.hs Map.hs], the standard finite map
 
* [http://darcs.haskell.org/packages/base/Data/Graph.hs Graph.hs], a graph type
 
* [http://darcs.haskell.org/packages/base/Data/Graph.hs Graph.hs], a graph type

Revision as of 05:19, 17 September 2006

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

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:

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:

  • Darcs, a revision control system (uses literate latex Haskell style)
  • Pugs, a perl6 implementation
  • Yi, a text editor
  • Conjure, a bittorrent client
  • DownNova, a file downloading program
  • cpphs, an implementation of the C preprocessor
  • GHC, a Haskell compiler (literate latex style)
  • Djinn, a theorem prover
  • c2hs, a C to Haskell interface generator
  • Lambdabot, an IRC bot
  • hmp3, an curses mp3 player
  • More code ...

3 Wiki examples

Here is a list of other random code collected on this wiki, replacing CodeOnTheWiki. Contributors of code to the old area are encouraged to bring their code over here. This should only be done by the original author because anything on these pages is automatically licensed under the Simple Permissive License (HaskellWiki:Copyrights).

Most examples are roughly intermediate to advanced in difficulty.