Difference between revisions of "Example code"

From HaskellWiki
Jump to navigation Jump to search
(More link updating)
(Removed an obsolete link)
Line 67: Line 67:
   
 
* [https://github.com/yi-editor/yi/blob/master/yi/src/library/Yi/Core.hs Yi], a text editor, ([http://www.haskell.org/haskellwiki/Yi home], [https://raw.github.com/yi-editor/yi/master/yi/src/library/Yi/Core.hs raw, [http://hackage.haskell.org/package/yi doc])
 
* [https://github.com/yi-editor/yi/blob/master/yi/src/library/Yi/Core.hs Yi], a text editor, ([http://www.haskell.org/haskellwiki/Yi home], [https://raw.github.com/yi-editor/yi/master/yi/src/library/Yi/Core.hs raw, [http://hackage.haskell.org/package/yi doc])
 
* [http://j.mongers.org/pub/haskell/darcs/conjure/Conjure/Torrent.hs Conjure], a bittorrent client
 
 
<!--
 
<!--
 
* [http://darcs.haskell.org/~lemmih/downNova/src/Torrent.hs DownNova], a file downloading program
 
* [http://darcs.haskell.org/~lemmih/downNova/src/Torrent.hs DownNova], a file downloading program

Revision as of 20:49, 25 February 2012

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 Learning Haskell, Haskell in 5 steps, and Books and tutorials.

More code may be found on the wiki.


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):

  • Unix.hs, simple unix tools, for beginner Haskellers


Application code

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

  • GHC, a Haskell compiler (literate latex style) (home)
  • c2hs, a C to Haskell interface generator (home)
  • hmp3, a curses mp3 player


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).
A tour of the Haskell Monad functions
Small usage examples of the basic Haskell monad functions