[Haskell-beginners] Re: testing and the culture of Haskell

Heinrich Apfelmus apfelmus at quantentunnel.de
Wed Jan 20 04:47:21 EST 2010

Michael Easter wrote:
> Q: If TDD is not advocated: why? Is there something about the Zen of Haskell
> development that is an impedance mismatch with TDD?

Static typing is a great help, it is not uncommon for Haskell code to be
correct on the first try once you convinced GHC that it's type correct.
There is much less need for TDD than in other languages.

Moreover, programming with pure functions offers a whole new approach to
program design. For instance, you can start with an inefficient but
obviously correct program and use laws and equations to rewrite that to
an efficient one. (You could call that "Proof Driven Design"). Here a
prime example:

   Richard Bird. A program to solve Sudoku.

> Q: Note that TDD and "writing tests" are different things. With respect to
> "writing tests", I know
> that HUnit exists and that RWH has a chapter on quality assurance.

The purpose of HUnit seems to be testing code that mainly involves IO.
For the purely functional part, people usually use QuickCheck because
you don't have to think about test cases, it will generate them

Heinrich Apfelmus


More information about the Beginners mailing list