The FunctorM library
Iavor Diatchki
iavor.diatchki at gmail.com
Sun Mar 20 17:11:48 EST 2005
Hello,
I was just looking at the FunctorM library that was recently added.
I have a few comments:
* Why is this library under "Data" and the rest of the monadic stuff
is under "Control"
(Related to this, what does the Reader monad have to do with Control?)
* A better name for this might be "forEach". This is what I added to
the Prelude of my monad library:
-- | Apply a monadic function to each element in a container.
-- In theory speak, this is a class that identifies functors which
-- distribute over all monads.
class ForEach f where
forEach :: Monad m => f a -> (a -> m b) -> m (f b)
instance ForEach [] where
forEach xs f = mapM f xs
instance ForEach Maybe where
forEach Nothing f = return Nothing
forEach (Just x) f = Just # f x
forEach_ :: (Monad m, ForEach f) => f a -> (a -> m b) -> m ()
forEach_ xs f = forEach xs f >> return ()
-Iavor
More information about the Libraries
mailing list