Re: [Haskell-cafe] Still stacking monad transformers

2008-10-13 Thread Jonathan Cast
On Mon, 2008-10-13 at 18:28 +0100, Andrew Coppin wrote: Reid Barton wrote: It's not difficult: the operation is called mplus :: MyMonad a - MyMonad a - MyMonad a and already exists (assuming the author of ListT has not forgotten to write a MonadPlus instance). I see... I was

Re: [Haskell-cafe] Still stacking monad transformers

2008-10-13 Thread Andrew Coppin
Reid Barton wrote: It's not difficult: the operation is called mplus :: MyMonad a - MyMonad a - MyMonad a and already exists (assuming the author of ListT has not forgotten to write a MonadPlus instance). I see... I was under the impression that mplus is just any arbitrary binary

Re: [Haskell-cafe] Still stacking monad transformers

2008-10-13 Thread Andrew Coppin
Jonathan Cast wrote: I see... I was under the impression that mplus is just any arbitrary binary operation over a given monad. How do you know what it does for a specific monad? Process of elimination. Sometimes, this doesn't narrow things down to a single operation, but it gives you a

Re: [Haskell-cafe] Still stacking monad transformers

2008-10-13 Thread Jonathan Cast
On Mon, 2008-10-13 at 18:58 +0100, Andrew Coppin wrote: Jonathan Cast wrote: I see... I was under the impression that mplus is just any arbitrary binary operation over a given monad. How do you know what it does for a specific monad? Process of elimination. Sometimes, this

Re: [Haskell-cafe] Still stacking monad transformers

2008-10-13 Thread Dino Morelli
On Mon, 13 Oct 2008, Andrew Coppin wrote: Reid Barton wrote: It's not difficult: the operation is called mplus :: MyMonad a - MyMonad a - MyMonad a and already exists (assuming the author of ListT has not forgotten to write a MonadPlus instance). I see... I was under the impression that

Re: [Haskell-cafe] Still stacking monad transformers

2008-10-13 Thread Arnar Birgisson
Hi Andrew, On Mon, Oct 13, 2008 at 19:58, Andrew Coppin [EMAIL PROTECTED] wrote: Right. OK. So... isn't there a class somewhere called MonadChoice or similar, which defines (|)? Just to pitch in a helpful tip, Hoogle is excellent for these kind of questions (which come up very often):

Re: [Haskell-cafe] Still stacking monad transformers

2008-10-13 Thread Tillmann Rendel
Dino Morelli wrote: I was wishing I could do this: let foo = str `or-if-empty` default If it was a Maybe, this works with mplus: (Just foo) `mplus` (Just bar) == Just foo Nothing `mplus` (Just bar) == Just bar But not so much for list, mplus just ain't defined that way,

[Haskell-cafe] Still stacking monad transformers

2008-10-12 Thread Andrew Coppin
I am becoming extremely frustrated now. The task I want to perform is simple, yet I simply cannot make Haskell do what I want. I've given up hope of ever getting my program to handle infinite result sets. That means I can make do with just ListT. So I have the following monad: type MyMonad

Re: [Haskell-cafe] Still stacking monad transformers

2008-10-12 Thread Duncan Coutts
On Sun, 2008-10-12 at 18:08 +0100, Andrew Coppin wrote: I am becoming extremely frustrated now. The task I want to perform is simple, yet I simply cannot make Haskell do what I want. I've given up hope of ever getting my program to handle infinite result sets. That means I can make do with

Re: [Haskell-cafe] Still stacking monad transformers

2008-10-12 Thread Miguel Mitrofanov
On 12 Oct 2008, at 21:08, Andrew Coppin wrote: I found that by using the brief and easily memorable construction runIdentity $ runListT $ runStateT foo state I can get at the result set for each action, and combine them. But nothing in hell seems to transform this from [((), MyState)]

Re: [Haskell-cafe] Still stacking monad transformers

2008-10-12 Thread David Menendez
On Sun, Oct 12, 2008 at 1:08 PM, Andrew Coppin [EMAIL PROTECTED] wrote: I am becoming extremely frustrated now. The task I want to perform is simple, yet I simply cannot make Haskell do what I want. I've given up hope of ever getting my program to handle infinite result sets. Did you miss

Re: [Haskell-cafe] Still stacking monad transformers

2008-10-12 Thread wren ng thornton
David Menendez wrote: On Sun, Oct 12, 2008 at 1:08 PM, Andrew Coppin [EMAIL PROTECTED] wrote: I am becoming extremely frustrated now. The task I want to perform is simple, yet I simply cannot make Haskell do what I want. I've given up hope of ever getting my program to handle infinite result