[Haskell-cafe] Building "production stable" software in Haskell

Neil Mitchell ndmitchell at gmail.com
Tue Sep 11 06:53:17 EDT 2007


> Well, I actually meant more something like the imperative equivalences
> of "code coverage tools" and "unit testing tools",

hpc and HUnit cover these two things pretty perfectly. hpc will be in
GHC 6.8, and its really cool :-)

> because I've read
> rumors that in Haskell, unit testing is more difficult because lazy
> evaluation will cause the "units" that got tested to be evaluated
> completely different depending on how they are used. In strict
> languages, this is not the case.

That's a really weird statement, and one that goes completely opposite
to my view of things. Do you have sources for these rumours? In a pure
language, if you evaluate some code it will do exactly the same thing
every time - there is no different behaviour. If you test the code,
then run it again later, you'll get the same result. Compare that to
something like C where:

int breakRandomly = 0;

int return42()
   breakRandomly = !breakRandomly;
   return (breakRandomly ? 666 : 42);

In C you can test this, and it will work, then you can test it twice
with identical values, and it will break.

Lazy evaluation can hide bugs if you only demand some small portion of
the output, but if your property/test is constructed properly, you
shouldn't have any problem.



More information about the Haskell-Cafe mailing list