From 73598b144efd71f201bda73a96564634f6cc2ed9 Mon Sep 17 00:00:00 2001 From: Erik de Castro Lopo Date: Sat, 22 Jun 2019 13:50:14 +1000 Subject: Add MonadFail instance for ParserM (cherry picked from commit 581cbc28e143a4ed8e7f794ed1618161222a5646) --- utils/genprimopcode/ParserM.hs | 11 +++++++++++ 1 file changed, 11 insertions(+) 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) -- cgit v1.2.1