diff options
author | Manuel M T Chakravarty <chak@cse.unsw.edu.au> | 2009-03-19 08:43:06 +0000 |
---|---|---|
committer | Manuel M T Chakravarty <chak@cse.unsw.edu.au> | 2009-03-19 08:43:06 +0000 |
commit | 5e5a08eb37f5513cecb47101a97fdaf09c4be040 (patch) | |
tree | 5dde9d2c44dc85c7bb32902b591daf2a367ca719 /compiler/utils | |
parent | 2c8d42f32022f4950606d75d53e45a4c30d210df (diff) | |
download | haskell-5e5a08eb37f5513cecb47101a97fdaf09c4be040.tar.gz |
Template Haskell: support for type family declarations
Diffstat (limited to 'compiler/utils')
-rw-r--r-- | compiler/utils/MonadUtils.hs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/compiler/utils/MonadUtils.hs b/compiler/utils/MonadUtils.hs index 20646572df..733eda1700 100644 --- a/compiler/utils/MonadUtils.hs +++ b/compiler/utils/MonadUtils.hs @@ -19,6 +19,7 @@ module MonadUtils , mapMaybeM , anyM, allM , foldlM, foldrM + , maybeMapM ) where ---------------------------------------------------------------------------------------- @@ -149,3 +150,8 @@ foldlM = foldM foldrM :: (Monad m) => (b -> a -> m a) -> a -> [b] -> m a foldrM _ z [] = return z foldrM k z (x:xs) = do { r <- foldrM k z xs; k x r } + +-- | Monadic version of fmap specialised for Maybe +maybeMapM :: Monad m => (a -> m b) -> (Maybe a -> m (Maybe b)) +maybeMapM _ Nothing = return Nothing +maybeMapM m (Just x) = liftM Just $ m x |