Hello!

In a CGI application I was gathering SQL statements I wanted to run in
the final transaction. Because I use haskelldb, it was most convenient
to use (Database -> IO ()) as the type of the statement or a group of
statements. In this representation concatenating two statement groups so
they are executed in sequence can be done with:

    concatStmts s1 s2 = \db -> s1 db >> s2 db

My mistake was that I forgot about db and wrote:

    concatStmts s1 s2 = s1 >> s2

And it was accepted because I had the Monad instance for ((->) r) in
scope (from Control.Monad.Trans I guess)!

Of course it doesn't do the right thing - s1 is simply ignored.
Fortunately I noticed it quite quickly, but I think a similar bug can
cause someone a big headache.

Perhaps we could move this instance to some separate module, so people
won't import it if they don't want it or even don't know about its
existence?

Best regards
Tomek
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to