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

2007-05-25 Thread Conal Elliott
Oops -- I wasn't watching this thread. I like Jules's definition, though I'd write it as follows. -- Standard instance: monad applied to monoid instance Monoid a = Monoid (IO a) where mempty = return mempty mappend = liftM2 mappend You can replace IO with any monad at all, to make similar

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

2007-05-16 Thread Tomasz Zielonka
On Tue, May 15, 2007 at 06:55:11AM -0700, Conal Elliott wrote: You could also use mappend instead of concatStmts and keep the Database - IO () representation.- Conal You mean using the (Monoid b) = Monoid (a - b) instance ? I can see that IO () makes a perfect Monoid, but there doesn't seem

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

2007-05-16 Thread Jules Bean
Tomasz Zielonka wrote: On Tue, May 15, 2007 at 06:55:11AM -0700, Conal Elliott wrote: You could also use mappend instead of concatStmts and keep the Database - IO () representation.- Conal You mean using the (Monoid b) = Monoid (a - b) instance ? I can see that IO () makes a

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

2007-05-16 Thread Tomasz Zielonka
On Wed, May 16, 2007 at 09:28:31AM +0100, Jules Bean wrote: Tomasz Zielonka wrote: You mean using the (Monoid b) = Monoid (a - b) instance ? I can see that IO () makes a perfect Monoid, but there doesn't seem to be a standard instance for that. Indeed, all Monads are Monoids (that is, if m

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

2007-05-16 Thread Jules Bean
Tomasz Zielonka wrote: On Wed, May 16, 2007 at 09:28:31AM +0100, Jules Bean wrote: Tomasz Zielonka wrote: You mean using the (Monoid b) = Monoid (a - b) instance ? I can see that IO () makes a perfect Monoid, but there doesn't seem to be a standard instance for that. Indeed, all

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

2007-05-15 Thread Arie Peterson
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

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

2007-05-15 Thread Tomasz Zielonka
On Tue, May 15, 2007 at 02:27:13PM +0200, Arie Peterson wrote: Hi Tomek! Hi! Have you considered changing the statements to have type 'ReaderT Database IO ()'? Then () actually does what you want. I tried it and it made the code simpler, more readable and of course more immune to this type

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

2007-05-15 Thread Conal Elliott
You could also use mappend instead of concatStmts and keep the Database - IO () representation.- Conal On 5/15/07, Arie Peterson [EMAIL PROTECTED] 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

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

2007-05-15 Thread Bjorn Bringert
On May 15, 2007, at 14:52 , Tomasz Zielonka wrote: On Tue, May 15, 2007 at 02:27:13PM +0200, Arie Peterson wrote: Hi Tomek! Hi! Have you considered changing the statements to have type 'ReaderT Database IO ()'? Then () actually does what you want. I tried it and it made the code