Use OPTIONS rather than OPTIONS_GHC for pragmas
[ghc-hetmet.git] / compiler / utils / Maybes.lhs
index 7d1fa4e..4e4726a 100644 (file)
@@ -4,6 +4,13 @@
 %
 
 \begin{code}
+{-# OPTIONS -w #-}
+-- The above warning supression flag is a temporary kludge.
+-- While working on this module you are encouraged to remove it and fix
+-- any warnings in the module. See
+--     http://hackage.haskell.org/trac/ghc/wiki/CodingStyle#Warnings
+-- for details
+
 module Maybes (
        module Data.Maybe,      -- Re-export all of Maybe
 
@@ -17,7 +24,7 @@ module Maybes (
        expectJust,
        maybeToBool,
 
-       thenMaybe, seqMaybe, returnMaybe, failMaybe
+       thenMaybe, seqMaybe, returnMaybe, failMaybe, fmapMMaybe
     ) where
 
 #include "HsVersions.h"
@@ -100,6 +107,11 @@ failMaybe = Nothing
 orElse :: Maybe a -> a -> a
 (Just x) `orElse` y = x
 Nothing  `orElse` y = y
+
+fmapMMaybe :: Monad m => (a -> m b) -> Maybe a -> m (Maybe b)
+fmapMMaybe f Nothing  = return Nothing
+fmapMMaybe f (Just x) = f x >>= \x' -> return (Just x')
+
 \end{code}