summaryrefslogtreecommitdiff
path: root/compiler/utils/Maybes.hs
diff options
context:
space:
mode:
authorDavid Luposchainsky <dluposchainsky@gmail.com>2015-11-17 17:10:02 +0100
committerBen Gamari <bgamari.foss@gmail.com>2015-11-17 12:29:09 -0500
commit233d1312bf15940fca5feca6884f965e7944b555 (patch)
tree0f787688562e65c1043626d8d03447ef2ab0b7a7 /compiler/utils/Maybes.hs
parent7b962bab384e2ae85b41d30f503c3d0295b0214f (diff)
downloadhaskell-233d1312bf15940fca5feca6884f965e7944b555.tar.gz
MonadFail proposal, phase 1
This implements phase 1 of the MonadFail proposal (MFP, #10751). - MonadFail warnings are all issued as desired, tunable with two new flags - GHC was *not* made warning-free with `-fwarn-missing-monadfail-warnings` (but it's disabled by default right now) Credits/thanks to - Franz Thoma, whose help was crucial to implementing this - My employer TNG Technology Consulting GmbH for partially funding us for this work Reviewers: goldfire, austin, #core_libraries_committee, hvr, bgamari, fmthoma Reviewed By: hvr, bgamari, fmthoma Subscribers: thomie Projects: #ghc Differential Revision: https://phabricator.haskell.org/D1248 GHC Trac Issues: #10751
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