
Is there a function which can do this, where m is not mplus? I would like all the lists to be joined inside the monad with ++.

On Wednesday 17 August 2011, 13:20:55, Guy wrote:
Is there a function which can do this, where m is not mplus?
I would like all the lists to be joined inside the monad with ++.
sequence gives you m [[a]], then an fmap concat (or liftM concat, since fmap requires an additional Functor constraint) flattens the resulting list to m [a].

On 17/08/2011 14:32, Daniel Fischer wrote:
On Wednesday 17 August 2011, 13:20:55, Guy wrote:
Is there a function which can do this, where m is not mplus?
I would like all the lists to be joined inside the monad with ++.
sequence gives you m [[a]], then an fmap concat (or liftM concat, since fmap requires an additional Functor constraint) flattens the resulting list to m [a].
Thanks. I was hoping that there would be some kind of fold that could do this; I take it there isn't one?

On Wednesday 17 August 2011, 14:05:43, Guy wrote:
On 17/08/2011 14:32, Daniel Fischer wrote:
On Wednesday 17 August 2011, 13:20:55, Guy wrote:
Is there a function which can do this, where m is not mplus?
I would like all the lists to be joined inside the monad with ++.
sequence gives you m [[a]], then an fmap concat (or liftM concat, since fmap requires an additional Functor constraint) flattens the resulting list to m [a].
Thanks. I was hoping that there would be some kind of fold that could do this; I take it there isn't one?
Well, sequence is a fold, and concat is a fold. You can fuse them foldr (\x xs -> x >>= \ys -> xs >>= \zs -> return (ys ++ zs)) (return []) but is that really more readable?

On Wed, Aug 17, 2011 at 01:32:00PM +0200, Daniel Fischer wrote:
On Wednesday 17 August 2011, 13:20:55, Guy wrote:
Is there a function which can do this, where m is not mplus?
I would like all the lists to be joined inside the monad with ++.
sequence gives you m [[a]], then an fmap concat (or liftM concat, since
http://spl.smugmug.com/Humor/Lambdacats/lift-concat/960794992_KUg77-M-1.jpg

mapM join On 08/17/2011 09:20 PM, Guy wrote:
Is there a function which can do this, where m is not mplus?
I would like all the lists to be joined inside the monad with ++.
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
-- Tony Morris http://tmorris.net/
participants (4)
-
Brent Yorgey
-
Daniel Fischer
-
Guy
-
Tony Morris