From fef03e755b5ba1d1d34e001e09b1968323f89324 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20K=C3=A4llberg?= Date: Tue, 4 Oct 2022 13:06:43 +0200 Subject: [PATCH 1/3] Update some old unused code to support newer ghc --- src/tools/c/GFCC/ErrM.hs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/tools/c/GFCC/ErrM.hs b/src/tools/c/GFCC/ErrM.hs index 78295d30e..872a8aec0 100644 --- a/src/tools/c/GFCC/ErrM.hs +++ b/src/tools/c/GFCC/ErrM.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE CPP #-} +{-# LANGUAGE DeriveFunctor #-} -- BNF Converter: Error Monad -- Copyright (C) 2004 Author: Aarne Ranta @@ -6,12 +8,17 @@ module GFCC.ErrM where -- Control.Monad.Fail import will become redundant in GHC 8.8+ import qualified Control.Monad.Fail as Fail +import Control.Monad (ap) -- the Error monad: like Maybe type with error msgs data Err a = Ok a | Bad String - deriving (Read, Show, Eq) + deriving (Read, Show, Eq, Functor) + +instance Applicative Err where + pure = Ok + (<*>) = ap instance Monad Err where return = Ok From 51b7117a3d0ae56118074112203d1f3f18402d0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20K=C3=A4llberg?= Date: Tue, 4 Oct 2022 13:05:57 +0200 Subject: [PATCH 2/3] Restore build with ghc-7.10.3 --- gf.cabal | 4 +++- src/compiler/GF/Interactive.hs | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/gf.cabal b/gf.cabal index da54010d1..3c3687de2 100644 --- a/gf.cabal +++ b/gf.cabal @@ -81,7 +81,9 @@ library mtl >= 2.2.1 && < 2.3, pretty >= 1.1.3 && < 1.2, random >= 1.1 && < 1.3, - utf8-string >= 1.0.1.1 && < 1.1 + utf8-string >= 1.0.1.1 && < 1.1, + -- We need this in order for ghc-7.10 to build + transformers-compat >= 0.6.3 && < 0.7 if impl(ghc<8.0) build-depends: diff --git a/src/compiler/GF/Interactive.hs b/src/compiler/GF/Interactive.hs index 676511680..a3a02af78 100644 --- a/src/compiler/GF/Interactive.hs +++ b/src/compiler/GF/Interactive.hs @@ -38,6 +38,8 @@ import GF.Server(server) #endif import GF.Command.Messages(welcome) +-- Needed to make it compile on GHC < 8 +import Control.Monad.Trans.Instances () -- | Run the GF Shell in quiet mode (@gf -run@). mainRunGFI :: Options -> [FilePath] -> IO () From 0a16b76875fa8d99c81a4e840083faff771b3cda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20K=C3=A4llberg?= Date: Tue, 4 Oct 2022 13:28:06 +0200 Subject: [PATCH 3/3] Only include transformers-compat for ghc < 8 Since that's the only place where it's needed and we don't have to fight with versions elsewhere --- gf.cabal | 6 +++--- src/compiler/GF/Interactive.hs | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/gf.cabal b/gf.cabal index 3c3687de2..022cc1e21 100644 --- a/gf.cabal +++ b/gf.cabal @@ -81,12 +81,12 @@ library mtl >= 2.2.1 && < 2.3, pretty >= 1.1.3 && < 1.2, random >= 1.1 && < 1.3, - utf8-string >= 1.0.1.1 && < 1.1, - -- We need this in order for ghc-7.10 to build - transformers-compat >= 0.6.3 && < 0.7 + utf8-string >= 1.0.1.1 && < 1.1 if impl(ghc<8.0) build-depends: + -- We need this in order for ghc-7.10 to build + transformers-compat >= 0.6.3 && < 0.7, fail >= 4.9.0 && < 4.10 hs-source-dirs: src/runtime/haskell diff --git a/src/compiler/GF/Interactive.hs b/src/compiler/GF/Interactive.hs index a3a02af78..1970533d6 100644 --- a/src/compiler/GF/Interactive.hs +++ b/src/compiler/GF/Interactive.hs @@ -38,8 +38,10 @@ import GF.Server(server) #endif import GF.Command.Messages(welcome) +#if !(MIN_VERSION_base(4,9,0)) -- Needed to make it compile on GHC < 8 import Control.Monad.Trans.Instances () +#endif -- | Run the GF Shell in quiet mode (@gf -run@). mainRunGFI :: Options -> [FilePath] -> IO ()