summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik de Castro Lopo <erikd@mega-nerd.com>2019-06-22 13:50:14 +1000
committerBen Gamari <ben@smart-cactus.org>2019-06-25 18:33:44 -0400
commit73598b144efd71f201bda73a96564634f6cc2ed9 (patch)
tree5d86a7b52ba23e60d0a4cd5d73c22a351fb5eb10
parent8dd80930a6be5393254cd4d1e9a3cf016fe59c8c (diff)
downloadhaskell-73598b144efd71f201bda73a96564634f6cc2ed9.tar.gz
Add MonadFail instance for ParserM
(cherry picked from commit 581cbc28e143a4ed8e7f794ed1618161222a5646)
-rw-r--r--utils/genprimopcode/ParserM.hs11
1 files changed, 11 insertions, 0 deletions
diff --git a/utils/genprimopcode/ParserM.hs b/utils/genprimopcode/ParserM.hs
index 190ec0edc0..1691bbaefb 100644
--- a/utils/genprimopcode/ParserM.hs
+++ b/utils/genprimopcode/ParserM.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE CPP #-}
module ParserM (
-- Parser Monad
ParserM(..), AlexInput, run_parser,
@@ -18,7 +19,13 @@ module ParserM (
) where
import Control.Applicative
+
+#if __GLASGOW_HASKELL__ >= 806
+import Prelude hiding (fail)
+import Control.Monad.Fail (MonadFail (..))
+#else
import Prelude
+#endif
import Control.Monad (ap, liftM)
import Data.Word (Word8)
@@ -42,6 +49,10 @@ instance Monad ParserM where
Left err ->
Left err
return a = ParserM $ \i s -> Right (i, s, a)
+
+#if __GLASGOW_HASKELL__ >= 806
+instance MonadFail ParserM where
+#endif
fail err = ParserM $ \_ _ -> Left err
run_parser :: ParserM a -> (String -> Either String a)