summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorAndreas Källberg <anka.213@gmail.com>2020-08-05 16:20:35 +0200
committerAndreas Källberg <anka.213@gmail.com>2020-08-05 18:48:24 +0200
commit251845f83ea52965b5205fd231ffa2c87bb34de6 (patch)
tree66b22f4370f09b673a44607ed1b0cc1294a2f74e /src/compiler
parentdeddde953f9e9b71e35a80bb29af0ce81e1dc6d0 (diff)
First attempt at fixing incompabilities with newer cabal
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/GF/Compile/TypeCheck/ConcreteNew.hs15
-rw-r--r--src/compiler/GF/Data/ErrM.hs19
-rw-r--r--src/compiler/GF/Grammar/Lexer.x13
-rw-r--r--src/compiler/GF/Infra/UseIO.hs11
4 files changed, 57 insertions, 1 deletions
diff --git a/src/compiler/GF/Compile/TypeCheck/ConcreteNew.hs b/src/compiler/GF/Compile/TypeCheck/ConcreteNew.hs
index 8fd6023b3..fab3173dc 100644
--- a/src/compiler/GF/Compile/TypeCheck/ConcreteNew.hs
+++ b/src/compiler/GF/Compile/TypeCheck/ConcreteNew.hs
@@ -19,6 +19,10 @@ import GF.Text.Pretty
import Data.List (nub, (\\), tails)
import qualified Data.IntMap as IntMap
import Data.Maybe(fromMaybe,isNothing)
+#if !MIN_VERSION_base(4,11,0)
+-- Control.Monad.Fail import is redundant since GHC 8.8.1
+import qualified Control.Monad.Fail as Fail
+#endif
checkLType :: GlobalEnv -> Term -> Type -> Check (Term, Type)
checkLType ge t ty = runTcM $ do
@@ -646,8 +650,19 @@ instance Monad TcM where
f >>= g = TcM (\ms msgs -> case unTcM f ms msgs of
TcOk x ms msgs -> unTcM (g x) ms msgs
TcFail msgs -> TcFail msgs)
+
+#if !(MIN_VERSION_base(4,13,0))
+ fail = tcError . pp
+#endif
+
+instance Fail.MonadFail TcM where
fail = tcError . pp
+
+-- Control.Monad.Fail import will become redundant in GHC 8.8+
+import qualified Control.Monad.Fail as Fail
+
+
instance Applicative TcM where
pure = return
(<*>) = ap
diff --git a/src/compiler/GF/Data/ErrM.hs b/src/compiler/GF/Data/ErrM.hs
index 033c1efac..0cef54816 100644
--- a/src/compiler/GF/Data/ErrM.hs
+++ b/src/compiler/GF/Data/ErrM.hs
@@ -16,6 +16,10 @@ module GF.Data.ErrM where
import Control.Monad (MonadPlus(..),ap)
import Control.Applicative
+#if !MIN_VERSION_base(4,11,0)
+-- Control.Monad.Fail import is redundant since GHC 8.8.1
+import qualified Control.Monad.Fail as Fail
+#endif
-- | Like 'Maybe' type with error msgs
data Err a = Ok a | Bad String
@@ -33,10 +37,23 @@ fromErr a = err (const a) id
instance Monad Err where
return = Ok
- fail = Bad
Ok a >>= f = f a
Bad s >>= f = Bad s
+#if !(MIN_VERSION_base(4,11,0))
+ fail = Bad
+#endif
+
+instance Fail.MonadFail Err where
+ fail = Bad
+
+-- Control.Monad.Fail import will become redundant in GHC 8.8+
+import qualified Control.Monad.Fail as Fail
+
+
+
+
+
-- | added 2\/10\/2003 by PEB
instance Functor Err where
fmap f (Ok a) = Ok (f a)
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)
diff --git a/src/compiler/GF/Infra/UseIO.hs b/src/compiler/GF/Infra/UseIO.hs
index e27b6e075..4c5a26d32 100644
--- a/src/compiler/GF/Infra/UseIO.hs
+++ b/src/compiler/GF/Infra/UseIO.hs
@@ -159,6 +159,9 @@ instance ErrorMonad IO where
then h (ioeGetErrorString e)
else ioError e
{-
+-- Control.Monad.Fail import will become redundant in GHC 8.8+
+import qualified Control.Monad.Fail as Fail
+
instance Functor IOE where fmap = liftM
instance Applicative IOE where
@@ -170,7 +173,15 @@ instance Monad IOE where
IOE c >>= f = IOE $ do
x <- c -- Err a
appIOE $ err raise f x -- f :: a -> IOE a
+
+ #if !(MIN_VERSION_base(4,13,0))
+ fail = raise
+ #endif
+
+instance Fail.MonadFail IOE where
fail = raise
+
+
-}
-- | Print the error message and return a default value if the IO operation 'fail's