From 233d1312bf15940fca5feca6884f965e7944b555 Mon Sep 17 00:00:00 2001 From: David Luposchainsky Date: Tue, 17 Nov 2015 17:10:02 +0100 Subject: 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 --- compiler/utils/IOEnv.hs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'compiler/utils/IOEnv.hs') diff --git a/compiler/utils/IOEnv.hs b/compiler/utils/IOEnv.hs index 31ac2b3731..804ddd8e70 100644 --- a/compiler/utils/IOEnv.hs +++ b/compiler/utils/IOEnv.hs @@ -43,6 +43,9 @@ import Data.Typeable import System.IO.Unsafe ( unsafeInterleaveIO ) import System.IO ( fixIO ) import Control.Monad +#if __GLASGOW_HASKELL__ > 710 +import qualified Control.Monad.Fail as MonadFail +#endif import MonadUtils import Control.Applicative (Alternative(..)) @@ -62,6 +65,12 @@ instance Monad (IOEnv m) where return = pure fail _ = failM -- Ignore the string +#if __GLASGOW_HASKELL__ > 710 +instance MonadFail.MonadFail (IOEnv m) where + fail _ = failM -- Ignore the string +#endif + + instance Applicative (IOEnv m) where pure = returnM IOEnv f <*> IOEnv x = IOEnv (\ env -> f env <*> x env ) -- cgit v1.2.1