From 7268253f5ae4b4883d28faa87b3e63295f04abfd Mon Sep 17 00:00:00 2001 From: Andreas Källberg Date: Sat, 5 Sep 2020 20:23:07 +0200 Subject: MonadFail: Make backwards-compatible --- src/compiler/GF/Data/ErrM.hs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/compiler/GF/Data/ErrM.hs') diff --git a/src/compiler/GF/Data/ErrM.hs b/src/compiler/GF/Data/ErrM.hs index 5ea7f0734..288c61919 100644 --- a/src/compiler/GF/Data/ErrM.hs +++ b/src/compiler/GF/Data/ErrM.hs @@ -12,10 +12,12 @@ -- hack for BNFC generated files. AR 21/9/2003 ----------------------------------------------------------------------------- +{-# LANGUAGE CPP #-} module GF.Data.ErrM where import Control.Monad (MonadPlus(..),ap) import Control.Applicative +import qualified Control.Monad.Fail as Fail -- | Like 'Maybe' type with error msgs data Err a = Ok a | Bad String @@ -36,7 +38,12 @@ instance Monad Err where Ok a >>= f = f a Bad s >>= f = Bad s -instance MonadFail Err where +#if !(MIN_VERSION_base(4,13,0)) + -- Monad(fail) will be removed in GHC 8.8+ + fail = Fail.fail +#endif + +instance Fail.MonadFail Err where fail = Bad -- cgit v1.2.3