[Haskell-cafe] TDD in Haskell

Ionut G. Stan ionut.g.stan at gmail.com
Tue May 25 08:36:46 EDT 2010


On 5/25/10 2:50 PM, Daniel Fischer wrote:
> 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.

Well, probably. I'm looking for an automated solution though. I want to 
be able to rerun the tests on every commit or version release.

>>
>> 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.

It may be true. I've got accustomed though to write code in iterative 
steps, where I first think about the smallest feature that I want to 
implement, then write the test, then again feature -> test -> code/refactor.

I will certainly have to adapt my work flow within the Haskell way of 
doing things, until then though I'll start from what I know has produced 
good results for me and change it along the way.

>
>>
>>
>> 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 thought so. Good to know.

>> I'm trying to learn from existing
>> packages, but all those "import all" statements drive me crazy.
>>
>> Thanks,
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>

Thanks,
-- 
Ionuț G. Stan  |  http://igstan.ro


More information about the Haskell-Cafe mailing list