summaryrefslogtreecommitdiff
path: root/compiler/utils/Maybes.hs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/utils/Maybes.hs')
-rw-r--r--compiler/utils/Maybes.hs9
1 files changed, 9 insertions, 0 deletions
diff --git a/compiler/utils/Maybes.hs b/compiler/utils/Maybes.hs
index 56b6dab5d9..656f40a372 100644
--- a/compiler/utils/Maybes.hs
+++ b/compiler/utils/Maybes.hs
@@ -20,6 +20,9 @@ module Maybes (
import Control.Applicative
import Control.Monad
+#if __GLASGOW_HASKELL__ > 710
+import Control.Monad.Fail
+#endif
import Data.Maybe
infixr 4 `orElse`
@@ -85,6 +88,12 @@ instance (Monad m) => Monad (MaybeT m) where
x >>= f = MaybeT $ runMaybeT x >>= maybe (pure Nothing) (runMaybeT . f)
fail _ = MaybeT $ pure Nothing
+
+#if __GLASGOW_HASKELL__ > 710
+instance Monad m => MonadFail (MaybeT m) where
+ fail _ = MaybeT $ return Nothing
+#endif
+
#if __GLASGOW_HASKELL__ < 710
-- Pre-AMP change
instance (Monad m, Applicative m) => Alternative (MaybeT m) where