352

What are some open source programs that use Haskell and can be considered to be good quality modern Haskell? The larger the code base, the better.

I want to learn from their source code. I feel I'm past the point of learning from small code examples, which are often to esoteric and small-world. I want to see how code is structured, how monads interact when you have a lot of things going on (logging, I/O, configuration, etc.).

blahdiblah
  • 30,909
  • 18
  • 92
  • 149
luispedro
  • 6,669
  • 3
  • 33
  • 45

7 Answers7

278

What I recommend.

Read code by people from different grad schools in the 1990s

Read code by the old masters certain people (incomplete list)

Note that people like me, Coutts, Mitchell, O'Sullivan, Lynagh, etc. learned our Haskell style from these guys.

Read some applications

dfeuer
  • 44,398
  • 3
  • 56
  • 155
Don Stewart
  • 134,643
  • 35
  • 355
  • 461
  • 103
    This is typical haskell damit. With php you read a hello world and go straight on writing poor web-sites. With haskell, there is no upper bound on what you can learn, there's always more interesting extensions and papers coming up. And just now I learned that universities have different styles, and therefor I must check all those out... When do I have time for actually writing haskell projects of my own? :) – Tarrasch Jun 18 '11 at 22:10
  • 39
    What, briefly, are the characteristics of the different styles? – grautur Jun 19 '11 at 19:00
  • 17
    @grautur: And, more importantly, why are they different? Were there good technical reasons? – Robert Massaioli Jun 20 '11 at 13:51
  • 1
    @robert massaioli: **Could** there be good technical reasons? – canisrufus Jun 20 '11 at 18:13
  • 10
    In my view, the different styles are the result of geographical separation (and sometimes philosophical disagreements) of the different schools in the pre-wiki/internet age; and the legacy of proto-Haskell languages at each school influencing the style. With the emergence of Hackage, wikis and github there is now largely a homogeneous Haskell style (based on Glasgow and GHC use). – Don Stewart Jun 20 '11 at 18:44
  • 2
    Browsing through the code linked above, I found it hard to really distinguish styles, actually. There's declarative vs. expressive, monadic vs. applicative, whitespace vs. semicolons, literate-bird vs. literate-latex vs. illiterate, but beyond that the way different code looks has much more to do with its core structure than anything else, I think. Except for Utrecht, which is just weird :-) – sclv Jun 20 '11 at 19:31
  • 4
    Utrecht is a language isolate :) – Don Stewart Jun 20 '11 at 19:36
  • 1
    What, no Kiselyov style? When you think you really understand Haskell, it's always good to read a bit of Oleg's code. – Jacques Carette Jun 21 '11 at 00:31
  • 1
    I've noticed that most of Don's source code examples do not include many inline comments. Is that by incident or "good Haskell style"? – LennyStackOverflow Jun 21 '11 at 08:12
  • 16
    At CMU, I learned denotational semantics and program derivation (systematic transformation of specifications to implementations), both of which have had a profound impact on my approach to programming. You'll see these two themes regularly on [my blog](http://conal.net). When I work on a software library, I pick a small number of types and start with a central question: "What does it mean?". When I see low-level code, e.g., imperative/`IO`, I ask "Of what denotative abstraction is this code an implementation, and how might that implementation be derived from the abstraction?" – Conal Jun 22 '11 at 06:12
  • @JacquesCarette, I suspect McBride makes a good complement to Kiselyov. Each has serious weaknesses from the perspective of learning good coding style. McBride seems generally not to care one whit about how long his programs take to run—he's really a mathematician. Kiselyov is a computer scientist more than a programmer. He really likes to stretch the outer limits of what the language he's working on can do. What he comes up with may be an impressive *encoding* of an idea, but not necessarily a practical way to express it. – dfeuer Oct 24 '17 at 21:44
  • @dfeuer I think you mistake Oleg and Conor's publications with the person as a whole. They have a lot more available code than what is in their papers. In papers, you make choices to illustrate ideas as plainly as possible. They have both built sound, practical systems too. – Jacques Carette Oct 25 '17 at 22:29
60

XMonad is an open source tiling window manager, originally loosely modeled on dwm. There are a lot of extensions, of varying quality, but the core is compact and well organized.

geekosaur
  • 53,509
  • 10
  • 113
  • 109
  • 37
    The core, fwiw, is also extremely carefully engineered. The core of the core, StackSet, has been verified (that is QC properties hold) in the Coq theorem prover. It is an example of pathological design care. – Don Stewart Jun 18 '11 at 21:49
  • 7
    @don: "pathological" as in "good", no? :) – Francesco Jun 19 '11 at 05:20
  • 9
    Yes :-) Spencer and I put more care into the crafting of the xmonad core than any project I've been involved in. – Don Stewart Jun 19 '11 at 05:21
19
  1. Haskell: Functional Programming with Types

    Joeri van Eekelen, et al. | Wikibooks Published in 2007, 290 pages

  2. Learn You a Haskell for Great Good!

    Miran Lipovaca | LearnYouaHaskell.com Published in 2010, 176 pages

  3. Real World Haskell

    B. O'Sullivan, J. Goerzen, D. Stewart | O'Reilly Media, Inc. Published in 2008, 710 pages

  4. The Haskell Road to Logic, Maths and Programming

    Kees Doets, Jan van Eijck | College Publications Published in 2004, 449 pages

Soner Gönül
  • 91,172
  • 101
  • 184
  • 324
17

Darcs is an open source, source code management system. It should give you a nice idea for Haskell.

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
Adithya Surampudi
  • 4,018
  • 13
  • 16
  • 16
    Having worked on darcs a fair bit, I wouldn't really recommend its source code. It doesn't use what I would consider good Haskell styles. I guess if you're curious what happens when small code bases get big while growing organically then it's a good example. If you want to see a program with a consistent writing style or clear design goals I would look elsewhere. – Jason Dagit Jun 20 '11 at 04:05
8

The source code to the Yesod Web Platform is fairly complex, well thought out, and well written. You will learn a lot from the persistence library that comes with it as well.

MattoxBeckman
  • 3,654
  • 2
  • 18
  • 16
7

If you care about Web-programming I would recommend Chris Done's lpaste project.

Jan Tojnar
  • 4,640
  • 3
  • 25
  • 44
Victor Nazarov
  • 755
  • 6
  • 10
6

GHC is probably the biggest or one of the biggest projects written in Haskell that is open source. When I say biggest, I do not just mean in terms of source size, but also impact, use, innovation, robustness. GHC can teach you a lot about writing Haskell.

danharaj
  • 1,513
  • 13
  • 19