Perspectives on learning and using Haskell

Jon Fairbairn Jon.Fairbairn at
Fri Jan 2 12:23:31 EST 2004

On 2004-01-01 at 21:07EST ajb at  wrote:
> There is only one problem I've found with test-driven development in
> Haskell.  In C++, it's possible to break the "module" abstraction
> (yes, I know, C++ doesn't have modules; it has classes, which are really
> instantiable modules) by using "friend".  In Haskell, I find myself
> occasionally having to expose parts of a module which I would prefer not
> to, in order for the unit tests suite to do their job effectively.
> I wonder if there might be a way to fix this, say, by allowing modules
> to selectively expose parts of their interface depending on who wants
> to use it.

One of my unexplored ideas is to make tests part of the code
of a module (probably best done with some sort of typed
include mechanism for test data), linked in some way with
the type of an entity.

So one might write something like

f :: Integer -> Integer |? f 0 == 1 && f 3 == 6

The compiler would then (optionally?) run the tests as part
of the compilation. This would bind the tests more tightly
to the programme than is now possible.

As I say, I haven't explored this, so perhaps some of those
agile minds out there could run with it?

Jón Fairbairn                                 Jon.Fairbairn at

More information about the Haskell-Cafe mailing list