From 251845f83ea52965b5205fd231ffa2c87bb34de6 Mon Sep 17 00:00:00 2001 From: Andreas Källberg Date: Wed, 5 Aug 2020 16:20:35 +0200 Subject: First attempt at fixing incompabilities with newer cabal --- src/compiler/GF/Grammar/Lexer.x | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/compiler/GF/Grammar') diff --git a/src/compiler/GF/Grammar/Lexer.x b/src/compiler/GF/Grammar/Lexer.x index d1550dd09..c19a32e3b 100644 --- a/src/compiler/GF/Grammar/Lexer.x +++ b/src/compiler/GF/Grammar/Lexer.x @@ -1,5 +1,6 @@ -- -*- haskell -*- { +{-# LANGUAGE CPP #-} module GF.Grammar.Lexer ( Token(..), Posn(..) , P, runP, runPartial, token, lexer, getPosn, failLoc @@ -18,6 +19,9 @@ import qualified Data.Map as Map import Data.Word(Word8) import Data.Char(readLitChar) --import Debug.Trace(trace) + +-- Control.Monad.Fail import will become redundant in GHC 8.8+ +import qualified Control.Monad.Fail as Fail } @@ -282,8 +286,17 @@ instance Monad P where (P m) >>= k = P $ \ s -> case m s of POk s a -> unP (k a) s PFailed posn err -> PFailed posn err + +#if !(MIN_VERSION_base(4,13,0)) + fail msg = P $ \(_,AI posn _ _) -> PFailed posn msg +#endif + +instance Fail.MonadFail P where fail msg = P $ \(_,AI posn _ _) -> PFailed posn msg + + + runP :: P a -> BS.ByteString -> Either (Posn,String) a runP p bs = snd <$> runP' p (Pn 1 0,bs) -- cgit v1.2.3