[Haskell-cafe] TDD in Haskell

Daniel Fischer daniel.is.fischer at web.de
Tue May 25 07:50:26 EDT 2010


On Tuesday 25 May 2010 13:36:01, Ionut G. Stan wrote:
> Hi,
>
> I'm doing TDD in pretty much all of the languages that I know, and I
> want to introduce it early in my Haskell learning process. I wonder
> though, if there's some established process regarding TDD, not unit
> testing.
>
> I've heard of QuickCheck and HUnit, but I've also read that QuickCheck
> is used mostly for testing pure code, while HUnit for impure code?

And ghci or hugs are the most used tools for testing, be the code pure or 
impure.

>
> What framework lends itself better for writing tests before the actual
> production code? Can you point out to some resources regarding this?

You can write the QuickCheck properties that your functions should satisfy 
before implementing the functions.
However, when you've determined the specs, it's rather unimportant whether 
you write the properties first or the functions, IMO.

>
>
> Oh, and a small off-topic question? Is it considered a good practice to
> use implicit imports in Haskell?

Generally, no. It's considered good practice to use explicit import (and 
export, of course) lists. But as lazy programmers, we can't always resist 
the temptation to skip some not strictly necessary work.
The implicit import of the entire Prelude is a special case, modules from 
the same package are edge cases, but otherwise it's a code smell.

> I'm trying to learn from existing
> packages, but all those "import all" statements drive me crazy.
>
> Thanks,



More information about the Haskell-Cafe mailing list