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):
- A Haskell 98 Prelude.hs, foundational Haskell library (raw, docs)
- Unix.hs, simple unix tools, for beginner Haskellers (raw)
- List.hs, the standard list library (raw, docs)
- Maybe.hs, the
Maybetype (raw, docs)
- Map.hs, the standard finite map (raw, docs)
- Graph.hs, a graph type (raw, docs)
- Monad.hs, basic monad support (raw, docs)
- QuickCheck.hs, a testing framework (raw, docs)
- PrettyPrint.hs, a pretty printing library (raw, docs)
- State.hs, a state monad (raw, docs)
- Music.hs, a music composition system (literate latex-style Haskell) (raw, home)
- Dfa.lhs, finite automata (literate Bird-style Haskell)
- RedBlackTree.hs, a red-black tree (raw)
- Prime.hs, prime numbers (raw)
- Foldable.hs, traversable data structures (raw)
- ByteString.hs, high-performance string type (raw, docs, home)
- SmallCheck.hs, a testing framework (raw)
- More code ...
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) (home)
- Pugs, a perl6 implementation (home)
- Yi, a text editor, (home)
- Conjure, a bittorrent client
- DownNova, a file downloading program
- cpphs, an implementation of the C preprocessor (home)
- GHC, a Haskell compiler (literate latex style) (home)
- Djinn, a theorem prover (home)
- c2hs, a C to Haskell interface generator (home)
- Lambdabot, an IRC bot (home)
- hmp3, an curses mp3 player (home)
- 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.
- Prelude extensions: Simple things you've always wished were in the Prelude.
- Gallery: Complete small programs.
- Blow your mind: Short, useful, cool, magical examples, which should incite the reader's curiosity and (hopefully) lead him to a deeper understanding of advanced Haskell concepts.
- Sudoku: Solvers for popular puzzle Sudoku
- NewMonads: Useful monads that are not in the main library.
- PrincipalVariationSearch: Principal variation search
- Shootout Entries: Examples still on the old wiki for the The Computer Language Shootout Benchmarks.
- Ralf Hinze maintains a Haskell software page