[Haskell-cafe] Monad fold

2013-04-16 Thread Christopher Howard
So, I'm doing something like this foldl (=) someA list :: Monad m = m a where list :: Monad m = [a - m a], someA :: Monad m = m a Is there a more concise way to write this? I don't think foldM is what I want -- or is it? -- frigidcode.com signature.asc Description: OpenPGP digital

Re: [Haskell-cafe] Monad fold

2013-04-16 Thread Lyndon Maydwell
You could do: runKleisli . mconcat . map Kleisli :: Monoid (Kleisli m a b) = [a - m b] - a - m b Would that work for you? On Tue, Apr 16, 2013 at 8:35 PM, Christopher Howard christopher.how...@frigidcode.com wrote: So, I'm doing something like this foldl (=) someA list :: Monad m = m a

Re: [Haskell-cafe] Monad fold

2013-04-16 Thread Oliver Charles
On 04/16/2013 01:47 PM, Lyndon Maydwell wrote: You could do: runKleisli . mconcat . map Kleisli :: Monoid (Kleisli m a b) = [a - m b] - a - m b Would that work for you? I can't find an instance for Monoid (Kleisli m a b) in `base`, so presumably the author would also have to write this

Re: [Haskell-cafe] Monad fold

2013-04-16 Thread Lyndon Maydwell
Wow looks like this Monoid instance isn't included in Control.Monad... My mistake. On Tue, Apr 16, 2013 at 8:47 PM, Lyndon Maydwell maydw...@gmail.com wrote: You could do: runKleisli . mconcat . map Kleisli :: Monoid (Kleisli m a b) = [a - m b] - a - m b Would that work for you? On

Re: [Haskell-cafe] Monad fold

2013-04-16 Thread Roman Cheplyaka
* Christopher Howard christopher.how...@frigidcode.com [2013-04-16 04:35:39-0800] So, I'm doing something like this foldl (=) someA list :: Monad m = m a where list :: Monad m = [a - m a], someA :: Monad m = m a Is there a more concise way to write this? I don't think foldM is

Re: [Haskell-cafe] Monad fold

2013-04-16 Thread Tom Ellis
On Tue, Apr 16, 2013 at 01:53:19PM +0100, Oliver Charles wrote: On 04/16/2013 01:47 PM, Lyndon Maydwell wrote: You could do: runKleisli . mconcat . map Kleisli :: Monoid (Kleisli m a b) = [a - m b] - a - m b Would that work for you? I can't find an instance for Monoid (Kleisli m a b) in

Re: [Haskell-cafe] Monad fold

2013-04-16 Thread Lyndon Maydwell
Yep. I was backstabbed by ghci seemingly having no issue with my definition when I asked for the type. On Tue, Apr 16, 2013 at 9:49 PM, Tom Ellis tom-lists-haskell-cafe-2...@jaguarpaw.co.uk wrote: On Tue, Apr 16, 2013 at 01:53:19PM +0100, Oliver Charles wrote: On 04/16/2013 01:47 PM, Lyndon

Re: [Haskell-cafe] Monad fold

2013-04-16 Thread Roman Cheplyaka
Right. See also this discussion: http://www.haskell.org/pipermail/libraries/2009-July/012106.html Roman * Tom Ellis tom-lists-haskell-cafe-2...@jaguarpaw.co.uk [2013-04-16 14:49:48+0100] On Tue, Apr 16, 2013 at 01:53:19PM +0100, Oliver Charles wrote: On 04/16/2013 01:47 PM, Lyndon Maydwell

Re: [Haskell-cafe] Monad fold

2013-04-16 Thread Arseniy Alekseyev
Hi! Although foldM won't make things much nicer, it can be used here as well: someA = \a - foldM (flip id) a list Cheers! Arseniy On 16 April 2013 13:35, Christopher Howard christopher.how...@frigidcode.com wrote: So, I'm doing something like this foldl (=) someA list :: Monad m = m a