summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik de Castro Lopo <erikd@mega-nerd.com>2019-06-22 13:50:14 +1000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-06-24 01:12:22 -0400
commit581cbc28e143a4ed8e7f794ed1618161222a5646 (patch)
tree11df96ea6f40cc8bec71aba930720ec8200b41b2
parent71aca77c780dad8496054a06a7fe65704a13a742 (diff)
downloadhaskell-581cbc28e143a4ed8e7f794ed1618161222a5646.tar.gz
Add MonadFail instance for ParserM
-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)