[<<][haskell][>>][..]Mon May 28 12:13:14 EDT 2018

https://stackoverflow.com/questions/17562345/generalizing-sequence-for-all-functors Slightly different interface but enough to do replace sequence,fmap with traverse,return. What I ran into was this: traverse :: (a -> f b) -> t a -> f (t b) generic (a -> m b) -> f a -> m (f b) specialized to mapping monadic function over a functor The specific version for Monad and List is traverse ' :: Monad m => (a -> m b) -> [a] -> m [b] traverse' f l = sequence $ map f l EDIT: actually, there is: sequence :: (Traversable t, Monad m) => t (m a) -> m (t a) http://hackage.haskell.org/package/base-4.11.1.0/docs/Data-Traversable.html#v:sequence sequence $ fmap _ _ == traverse _ _ I keep using the former... Seems more readable and also since there is no 2-arg traverse version? E.g. sequence $ liftA2 _ _ _

[Reply][About]

[<<][haskell][>>][..]