1 -----------------------------------------------------------------------------
3 -- Module : Data.FunctorM
4 -- Copyright : (c) The University of Glasgow 2005
5 -- License : BSD-style (see the file libraries/base/LICENSE)
7 -- Maintainer : libraries@haskell.org
8 -- Stability : provisional
9 -- Portability : portable
11 -- fmapM generalises fmap, just as mapM generalises map.
13 -- NOTE: This module is DEPRECATED.
14 -- The classes in "Data.Foldable" and "Data.Traversable" provide a
15 -- more general interface.
17 -----------------------------------------------------------------------------
20 {-# DEPRECATED "Use the more general Data.Foldable and Data.Traversable instead" #-}
26 class FunctorM f where
27 fmapM :: Monad m => (a -> m b) -> f a -> m (f b)
28 fmapM_ :: Monad m => (a -> m b) -> f a -> m ()
30 fmapM_ f t = fmapM f t >> return ()
32 instance FunctorM [] where
36 instance FunctorM Maybe where
37 fmapM _ Nothing = return Nothing
38 fmapM f (Just x) = f x >>= return . Just
40 fmapM_ _ Nothing = return ()
41 fmapM_ f (Just x) = f x >> return ()
43 instance Ix i => FunctorM (Array i) where
45 a' <- sequence [ f e >>= return . (,) i | (i,e) <- assocs a]
46 return (array (bounds a) a')