Re: [Haskell-cafe] concatMap generalizes to msumMap?
On Mon, May 16, 2005 at 02:57:42PM -0400, S. Alexander Jacobson wrote: What is the name of the monadic generalization of concatMap? (=) or simply (=) if you don't care about argument order. Probably not what you are after? In which lib is it located? The former is in module Monad, the latter in Prelude. Best regards Tomasz ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] concatMap generalizes to msumMap?
I don't think that is right. concatMap has definition concatMap :: (a - [b]) - [a] - [b] concatMap f xs = concat $ map f xs Therefore: msumMap :: (MonadPlus m) = (a1 - m a) - [a1] - m a msumMap f list = msum $ fmap f list In contrast = has type (=) :: (Monad m) = (a - m b) - m a - m b -Alex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com On Mon, 16 May 2005, Tomasz Zielonka wrote: On Mon, May 16, 2005 at 02:57:42PM -0400, S. Alexander Jacobson wrote: What is the name of the monadic generalization of concatMap? (=) or simply (=) if you don't care about argument order. Probably not what you are after? In which lib is it located? The former is in module Monad, the latter in Prelude. Best regards Tomasz ** CRM114 Whitelisted by: [EMAIL PROTECTED] ** ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] concatMap generalizes to msumMap?
On Mon, May 16, 2005 at 03:20:25PM -0400, S. Alexander Jacobson wrote: I don't think that is right. concatMap has definition concatMap :: (a - [b]) - [a] - [b] concatMap f xs = concat $ map f xs Therefore: msumMap :: (MonadPlus m) = (a1 - m a) - [a1] - m a msumMap f list = msum $ fmap f list In contrast = has type (=) :: (Monad m) = (a - m b) - m a - m b However: Prelude Control.Monad concatMap (\i - [i,i]) [1,2,3] [1,1,2,2,3,3] Prelude Control.Monad (=) (\i - [i,i]) [1,2,3] [1,1,2,2,3,3] You could define concatMap as = concatMap :: (a - [b]) - [a] - [b] concatMap = (=) I guess you don't want it that general. (=) for IO doesn't resemble concatMap. Best regards Tomasz ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] concatMap generalizes to msumMap?
S. Alexander Jacobson writes: I don't think that is right. concatMap has definition concatMap :: (a - [b]) - [a] - [b] concatMap f xs = concat $ map f xs Therefore: msumMap :: (MonadPlus m) = (a1 - m a) - [a1] - m a msumMap f list = msum $ fmap f list Assuming your goal is to generalize by replacing (++) with mplus, you want this: msumMap f = foldr (mplus . f) mzero It isn't in the standard libraries, so you'll have to define it yourself. -- David Menendez [EMAIL PROTECTED] | In this house, we obey the laws http://www.eyrie.org/~zednenem |of thermodynamics! ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe