[Haskell-cafe] Re: The danger of Monad ((->) r)

Conal Elliott conal at conal.net
Tue May 15 09:55:11 EDT 2007


You could also use mappend instead of concatStmts and keep the Database ->
IO () representation.    - Conal

On 5/15/07, Arie Peterson <ariep at xs4all.nl> wrote:
>
> Hi Tomek!
>
>
> > 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)!
>
> Have you considered changing the statements to have type 'ReaderT Database
> IO ()'? Then (>>) actually does what you want.
>
>
> Pozdrawiam,
>
> Arie
>
>
> --
>
> Always go along with the group, or someone may drop a sixteen-ton safe on
> you.
>   - The Buddy Bears
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20070515/f9e365dc/attachment-0001.htm


More information about the Haskell-Cafe mailing list