[Haskell-beginners] testing and the culture of Haskell

Stephen Tetley stephen.tetley at gmail.com
Mon Jan 18 12:20:14 EST 2010

Hello Michael

How about - Type Driven Development?

Personally, I like to work out the type a function should have, then
set about writing it. So I usually start from the type signature and
stub out the right-hand side of the definition (i.e. all the function
after the equals sign) with 'undefined'. Working like this is far from
universal in functional programming - it would be unnatural in Scheme
for instance, though some people using PLT Scheme appear to start
development by writing contract signatures. It certainly isn't
universal in Haskell either - some people like to write their
functions then fill in the type signature afterwards (if you do it
this way, providing your function compiles, you can query its 'most
general' type at GHCi's prompt).

ML used to have the proviso that type checking was always guaranteed
to terminate so type signatures were discretionary, I'm not sure if
this is still the case with O'Caml as it now seems to have quite an
extended type system. Certain bits of Haskell need explicit type
signatures - one example is polymorphic recursion.

I suspect very few people programming in Haskell use tests as the
primary 'driver' of their program designs (my interpretation of Test
Driven Developments slogans is that testing very much drives design).
I'd guess quite a number of people develop 'in tandem' with QuickCheck
(rather than strictly 'first' with QuickCheck) - for example, there is
a blog post on the XMonad window system covering how the authors
worked in this way.


Best wishes


> I'm a fan of Haskell but I can't say that I know the culture yet.

PS. I'd like to think Haskell has at least 'cultures' (or schools,
factions?) rather than a unified culture or way. If you like
developing test-first, why change if it works.

More information about the Beginners mailing list