
Looks interesting.
I've also come across Data.List.Class:
http://hackage.haskell.org/packages/archive/generator/0.5.1/doc/html/Data-Li...
Has anyone used that?
Kevin
On Jul 27, 6:02 pm, wren ng thornton
Kevin Jardine wrote:
But as I said, that is just an example. I keep wanting to apply the usual list tools but find that they do not work inside a monad. I find myself wishing that f (m [a]) just automatically returned m f([a])
Are you looking for these?
import Data.Traversable as T T.sequence :: (T.Traversable t, Monad m) => t (m a) -> m (t a) T.mapM :: (T.Traversable t, Monad m) => (a -> m b) -> t a -> m (t b) -- N.B. T.mapM ~ (T.sequence . fmap)
without me needing to do anything but I expect that there are reasons why that is not a good idea.
Not all functors can be distributed over arbitrary monads, so "not a good idea" is more like "not always possible" or "here be dragons" (fluffy, intriguing, and pretty dragons to be sure; but probably deeper than the answer you were looking for).
In addition to Applicative, the Traversable and Foldable classes should be key tools in your toolbox. They take a number of functions typically restricted to lists and generalize them to different functors, often with Applicatives or Monads involved. The Typeclassopedia should have more on them.
-- Live well, ~wren _______________________________________________ Haskell-Cafe mailing list Haskell-C...@haskell.orghttp://www.haskell.org/mailman/listinfo/haskell-cafe