[Haskell-cafe] Amazing

Felipe Lessa felipe.lessa at gmail.com
Sat Feb 14 19:57:02 EST 2009


As this topic popped out, my secrets for programming in Haskell are
three words: assert, HUnit, QuickCheck.

- Create internal functions that verify the results of the exported
ones, or maybe an easier to verify implementation that is slower, and
put them on assert's. This has saved me a few times.

- Create HUnit tests before writing the function itself (but after
writing its type), and automate the execution (maybe with
test-framework-hunit). This way you can test your implementation after
type-checking, optimizations and/or fixed bugs.

- If you can write down properties and Arbitrary's easily, do so and
wire everything with the HUnit tests. I don't use QuickCheck as I use
HUnit because it is often impossible to write meaningful Arbitrary
instances (haven't tried SmallCheck yet, but most of the time the
problem is with some kind of data type with lots of invariants to be
maintained).

Creating tests before the implementation + Haskell = Very few bugs +
Almost no regressions

-- 
Felipe.


More information about the Haskell-Cafe mailing list