[Haskell-cafe] ANNOUNCE: torch-0.1

Yusaku Hashimoto nonowarn at gmail.com
Tue Mar 10 12:06:58 EDT 2009


I have wrote and uploaded my unit test library (or framework)  
torch-0.1 on Hackage.

With torch, We can write simple unit test and run like this:

 > import Test.Torch
 > main = run $ do
 >   ok (odd 1) "assertion"
 >   is 42 (7*6) "equality assertion"
 >   isBottom (error undefined) "check whether value is bottom"
 >   ans <- liftIO (putStr "\n5 + 7 = " >> readLn)
 >   is ans 12 "sanity check :)"

Despite QuickCheck and HUnit, Why I wrote unit test library now?  
There is two reasons.

1. QuickCheck is not all-round

QuickCheck is awesome. But I often can't write Property when I want  
to test things, like not pure function. Even for pure function, I  
can't write Property by thinking _laws_ behind that with probability  
about 0.5. When I can't write Property, I want to write unit test  
using HUnit. But for me, HUnit does not fit to my hands. Because it  
is annoying that writing list of test literally in source code and  
confusing operators (I still can't remember distinction between (@=?)  
and (@?=)) This means when I read test written in HUnit, I can't read  
this without Documentation. And I got an idea for expressing  
structure of tests from a blog post about Monoid and Writer Monad.

2. Try to realize an idea that Writer monad can be treated as Monoid  
(and list of Test is Monoid)

I read sigfpe's great blog post (http://blog.sigfpe.com/2009/01/ 
haskell-monoids-and-their-uses.html) and hit upon the idea that  
considering Writer as Monoid, list of tests can be expressed with  
Monad. And I tried to realize it, and want to sympathize this idea  
with Haskellers. I think almost complete realizing this idea in the  

Those is why I wrote this library. And It is my first package on  
Hackage, I apologize for any wrong about packaging.

I hope you'll enjoy this!


More information about the Haskell-Cafe mailing list