[Haskell-cafe] Type System vs Test Driven Development

Erik de Castro Lopo mle+hs at mega-nerd.com
Wed Jan 5 11:05:49 CET 2011

Jonathan Geddes wrote:


> So, am I missing the benefits of TDD in my Haskell code?

Probably. I work on a project which has 40000+ lines of
haskell code (a compiler written in haskell) and has a huge
test suite that is a vital to continued development.

I've also written relatively small functions (eg a function
to find if a graph has cycles) that was wrong first time I
wrote it. During debugging I wrote a test that I'm keeping
as part of the unit tests. 

Furthermore tests are also useful for preventing regressions
(something the programmer is doing today, breaks something
that was working 6 months ago). Without tests, that breakage
may go un-noticed.

> I explained these thoughts to a fellow programmer who is not familiar
> with Haskell and his response was essentially that any language that
> discourages you from writing unit tests is a very poor language.

Haskell most certainly does not discourage anyone from writing
tests. One simply needs to look at the testing category of


to find 36 packages for doing testing.

> Am I putting too much faith in the type system?


> [0] http://blog.jayfields.com/2008/02/static-typing-considered-harmful.html

Complete bollocks!

Good type systems combined with good testing leads to better
code than either good type systems or good testing alone.

Erik de Castro Lopo

More information about the Haskell-Cafe mailing list