[Haskell-cafe] Type System vs Test Driven Development

Sönke Hahn shahn at cs.tu-berlin.de
Wed Jan 5 15:30:36 CET 2011

Erik de Castro Lopo wrote:

> Jonathan Geddes wrote:
> <snip>
>> 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.


If I may, I would like to agree with you both: A test suite should ideally 
cover all the aspects of the tested program, that are not checked statically 
by the compiler. So in python, I end up writing test cases that check for 
runtime type errors; in haskell, I don't. In both languages, it's good 
advice to write a test suite that checks the correctness of calculated 

Haskell's static type system feels to me like an automatically generated, 
somehow dumb test suite. It does not replace a full-flegded hand-written 
one, but it does replace a big part of it (that is, of what you would have 
to write in a dynamic language). And it runs much faster.

I also tend to write test suites when I feel, the code exceeds a certain 
level of complexity. This level is language dependent and in haskell's case, 
it's pretty high. (I should probably lower that level and write more test 
cases, but that seems to be true for all languages.)

And yes, haskell has great support for writing test suites.

More information about the Haskell-Cafe mailing list