[Haskell-cafe] Std lib equivalent for liftM concat . sequence
Yitzchak Gale
gale at sefer.org
Sun May 18 09:58:39 EDT 2008
Alistair Bayley wrote:
>> A couple of days ago I had need for:
>> concatM :: Monad m => [m [a]] -> m [a]
>> concatM = liftM concat . sequence
>> but found no such thing in the std libs
It used to be in an older version of Haskell, but
it was removed in Haskell 98.
Bulat Ziganshin wrote:
> 2. it's not widely used.
Bulat is justifiably concerned about backwards compatibility
issues when changing the core standard libraries, including
when adding new functions.
Despite Bulat's best efforts, there has been a trend lately
of adding those kinds of things.
If so, nowadays it can be made more general. In this
case, you could at least generalize it to:
concatM :: (Monad m, Traversable t, Foldable t, MonadPlus p) =>
t (m (p a)) -> m (p a)
or
concatA :: (Applicative f, Traversable t, Foldable t, MonadPlus p) =>
t (f (p a)) -> f (p a)
I'm sure someone can do better than that. :)
Regards,
Yitz
More information about the Haskell-Cafe
mailing list