From 820d2d503fde7b29634262fd07db2a4744cf813d Mon Sep 17 00:00:00 2001 From: Thomas Hallgren Date: Wed, 18 Apr 2018 19:18:10 +0200 Subject: [PATCH] Fixes for GHC 8.4.1 compatibility * In GHC 8.4.1, the operator <> has become a method of the Semigroup class and is exported from the Prelude. This is unfortunate, since <> is also exported from the standard library module Text.PrettyPrint, so in any module that defines a pretty printer, there is likely to be an ambiguity. This affects ~18 modules in GF. Solution: import Prelude hiding (<>) This works also in older versions of GHC, since GHC does't complain if you hide something that doesn't exists. * In GHC 8.4.1, Semigroup has become a superclass of Monoid. This means that anywhere you define an instance of the Monoid class you also have to define an instance in the Semigroup class. This affects Data.Binary.Builder in GF. Solution: conditionally define a Semigroup instance if compiling with base>=4.11 (ghc>=8.4.1) --- src/compiler/GF/Command/Commands.hs | 2 +- src/compiler/GF/Command/Commands2.hs | 2 +- src/compiler/GF/Compile/CheckGrammar.hs | 1 + src/compiler/GF/Compile/Compute/ConcreteNew.hs | 1 + src/compiler/GF/Compile/TypeCheck/RConcrete.hs | 1 + src/compiler/GF/CompileInParallel.hs | 2 +- src/compiler/GF/Grammar/Printer.hs | 1 + src/compiler/GF/Haskell.hs | 1 + src/compiler/GF/Infra/CheckM.hs | 1 + src/compiler/GF/Infra/Location.hs | 1 + src/compiler/GF/Speech/GSL.hs | 1 + src/compiler/GF/Speech/JSGF.hs | 1 + src/compiler/GF/Speech/SRGS_ABNF.hs | 1 + src/runtime/haskell-bind/PGF2.hsc | 2 +- src/runtime/haskell/Data/Binary/Builder.hs | 5 +++++ src/runtime/haskell/PGF/ByteCode.hs | 2 +- src/runtime/haskell/PGF/Macros.hs | 1 + src/runtime/haskell/PGF/Printer.hs | 1 + src/runtime/haskell/PGF/VisualizeTree.hs | 1 + 19 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/compiler/GF/Command/Commands.hs b/src/compiler/GF/Command/Commands.hs index 3ca2ab962..a8a175f7c 100644 --- a/src/compiler/GF/Command/Commands.hs +++ b/src/compiler/GF/Command/Commands.hs @@ -3,7 +3,7 @@ module GF.Command.Commands ( PGFEnv,HasPGFEnv(..),pgf,mos,pgfEnv,pgfCommands, options,flags, ) where -import Prelude hiding (putStrLn) +import Prelude hiding (putStrLn,(<>)) -- GHC 8.4.1 clash with Text.PrettyPrint import PGF diff --git a/src/compiler/GF/Command/Commands2.hs b/src/compiler/GF/Command/Commands2.hs index 0cc5d7d23..b5335479c 100644 --- a/src/compiler/GF/Command/Commands2.hs +++ b/src/compiler/GF/Command/Commands2.hs @@ -3,7 +3,7 @@ module GF.Command.Commands2 ( PGFEnv,HasPGFEnv(..),pgf,concs,pgfEnv,emptyPGFEnv,pgfCommands, options, flags, ) where -import Prelude hiding (putStrLn) +import Prelude hiding (putStrLn,(<>)) -- GHC 8.4.1 clash with Text.PrettyPrint import PGF2 import qualified PGF as H diff --git a/src/compiler/GF/Compile/CheckGrammar.hs b/src/compiler/GF/Compile/CheckGrammar.hs index 5c1743b74..1348d8e41 100644 --- a/src/compiler/GF/Compile/CheckGrammar.hs +++ b/src/compiler/GF/Compile/CheckGrammar.hs @@ -21,6 +21,7 @@ ----------------------------------------------------------------------------- module GF.Compile.CheckGrammar(checkModule) where +import Prelude hiding ((<>)) -- GHC 8.4.1 clash with Text.PrettyPrint import GF.Infra.Ident import GF.Infra.Option diff --git a/src/compiler/GF/Compile/Compute/ConcreteNew.hs b/src/compiler/GF/Compile/Compute/ConcreteNew.hs index a77da88bf..f9edc931c 100644 --- a/src/compiler/GF/Compile/Compute/ConcreteNew.hs +++ b/src/compiler/GF/Compile/Compute/ConcreteNew.hs @@ -5,6 +5,7 @@ module GF.Compile.Compute.ConcreteNew normalForm, Value(..), Bind(..), Env, value2term, eval, vapply ) where +import Prelude hiding ((<>)) -- GHC 8.4.1 clash with Text.PrettyPrint import GF.Grammar hiding (Env, VGen, VApp, VRecType) import GF.Grammar.Lookup(lookupResDefLoc,allParamValues) diff --git a/src/compiler/GF/Compile/TypeCheck/RConcrete.hs b/src/compiler/GF/Compile/TypeCheck/RConcrete.hs index 2fe08b256..88e324ff3 100644 --- a/src/compiler/GF/Compile/TypeCheck/RConcrete.hs +++ b/src/compiler/GF/Compile/TypeCheck/RConcrete.hs @@ -1,5 +1,6 @@ {-# LANGUAGE PatternGuards #-} module GF.Compile.TypeCheck.RConcrete( checkLType, inferLType, computeLType, ppType ) where +import Prelude hiding ((<>)) -- GHC 8.4.1 clash with Text.PrettyPrint import GF.Infra.CheckM import GF.Data.Operations diff --git a/src/compiler/GF/CompileInParallel.hs b/src/compiler/GF/CompileInParallel.hs index 7986656ec..8420b1771 100644 --- a/src/compiler/GF/CompileInParallel.hs +++ b/src/compiler/GF/CompileInParallel.hs @@ -1,6 +1,6 @@ -- | Parallel grammar compilation module GF.CompileInParallel(parallelBatchCompile) where -import Prelude hiding (catch) +import Prelude hiding (catch,(<>)) -- GHC 8.4.1 clash with Text.PrettyPrint import Control.Monad(join,ap,when,unless) import Control.Applicative import GF.Infra.Concurrency diff --git a/src/compiler/GF/Grammar/Printer.hs b/src/compiler/GF/Grammar/Printer.hs index dcd419c42..4b19d215b 100644 --- a/src/compiler/GF/Grammar/Printer.hs +++ b/src/compiler/GF/Grammar/Printer.hs @@ -22,6 +22,7 @@ module GF.Grammar.Printer , ppMeta , getAbs ) where +import Prelude hiding ((<>)) -- GHC 8.4.1 clash with Text.PrettyPrint import GF.Infra.Ident import GF.Infra.Option diff --git a/src/compiler/GF/Haskell.hs b/src/compiler/GF/Haskell.hs index e2156ac5d..57601c1d5 100644 --- a/src/compiler/GF/Haskell.hs +++ b/src/compiler/GF/Haskell.hs @@ -1,6 +1,7 @@ -- | Abstract syntax and a pretty printer for a subset of Haskell {-# LANGUAGE DeriveFunctor #-} module GF.Haskell where +import Prelude hiding ((<>)) -- GHC 8.4.1 clash with Text.PrettyPrint import GF.Infra.Ident(Ident,identS) import GF.Text.Pretty diff --git a/src/compiler/GF/Infra/CheckM.hs b/src/compiler/GF/Infra/CheckM.hs index 3b6833f0f..c5f9ba255 100644 --- a/src/compiler/GF/Infra/CheckM.hs +++ b/src/compiler/GF/Infra/CheckM.hs @@ -18,6 +18,7 @@ module GF.Infra.CheckM checkIn, checkInModule, checkMap, checkMapRecover, parallelCheck, accumulateError, commitCheck, ) where +import Prelude hiding ((<>)) -- GHC 8.4.1 clash with Text.PrettyPrint import GF.Data.Operations --import GF.Infra.Ident diff --git a/src/compiler/GF/Infra/Location.hs b/src/compiler/GF/Infra/Location.hs index 0bf85b37f..8447a297c 100644 --- a/src/compiler/GF/Infra/Location.hs +++ b/src/compiler/GF/Infra/Location.hs @@ -1,5 +1,6 @@ -- | Source locations module GF.Infra.Location where +import Prelude hiding ((<>)) -- GHC 8.4.1 clash with Text.PrettyPrint import GF.Text.Pretty -- ** Source locations diff --git a/src/compiler/GF/Speech/GSL.hs b/src/compiler/GF/Speech/GSL.hs index d9d6af0cc..a898a4bb5 100644 --- a/src/compiler/GF/Speech/GSL.hs +++ b/src/compiler/GF/Speech/GSL.hs @@ -7,6 +7,7 @@ ----------------------------------------------------------------------------- module GF.Speech.GSL (gslPrinter) where +import Prelude hiding ((<>)) -- GHC 8.4.1 clash with Text.PrettyPrint --import GF.Data.Utilities import GF.Grammar.CFG diff --git a/src/compiler/GF/Speech/JSGF.hs b/src/compiler/GF/Speech/JSGF.hs index 25168dbc8..15f5ff69d 100644 --- a/src/compiler/GF/Speech/JSGF.hs +++ b/src/compiler/GF/Speech/JSGF.hs @@ -11,6 +11,7 @@ ----------------------------------------------------------------------------- module GF.Speech.JSGF (jsgfPrinter) where +import Prelude hiding ((<>)) -- GHC 8.4.1 clash with Text.PrettyPrint --import GF.Data.Utilities import GF.Infra.Option diff --git a/src/compiler/GF/Speech/SRGS_ABNF.hs b/src/compiler/GF/Speech/SRGS_ABNF.hs index 75d206a0c..dc5c7bbd3 100644 --- a/src/compiler/GF/Speech/SRGS_ABNF.hs +++ b/src/compiler/GF/Speech/SRGS_ABNF.hs @@ -18,6 +18,7 @@ ----------------------------------------------------------------------------- module GF.Speech.SRGS_ABNF (srgsAbnfPrinter, srgsAbnfNonRecursivePrinter) where +import Prelude hiding ((<>)) -- GHC 8.4.1 clash with Text.PrettyPrint --import GF.Data.Utilities import GF.Infra.Option diff --git a/src/runtime/haskell-bind/PGF2.hsc b/src/runtime/haskell-bind/PGF2.hsc index fb3672c0f..895d13ca4 100644 --- a/src/runtime/haskell-bind/PGF2.hsc +++ b/src/runtime/haskell-bind/PGF2.hsc @@ -82,7 +82,7 @@ module PGF2 (-- * PGF LiteralCallback,literalCallbacks ) where -import Prelude hiding (fromEnum) +import Prelude hiding (fromEnum,(<>)) -- GHC 8.4.1 clash with Text.PrettyPrint import Control.Exception(Exception,throwIO) import Control.Monad(forM_) import System.IO.Unsafe(unsafePerformIO,unsafeInterleaveIO) diff --git a/src/runtime/haskell/Data/Binary/Builder.hs b/src/runtime/haskell/Data/Binary/Builder.hs index 03531daa7..b69371f0e 100644 --- a/src/runtime/haskell/Data/Binary/Builder.hs +++ b/src/runtime/haskell/Data/Binary/Builder.hs @@ -100,6 +100,11 @@ newtype Builder = Builder { runBuilder :: (Buffer -> [S.ByteString]) -> Buffer -> [S.ByteString] } +#if MIN_VERSION_base(4,11,0) +instance Semigroup Builder where + (<>) = append +#endif + instance Monoid Builder where mempty = empty {-# INLINE mempty #-} diff --git a/src/runtime/haskell/PGF/ByteCode.hs b/src/runtime/haskell/PGF/ByteCode.hs index 579d6b3bb..ef21ab229 100644 --- a/src/runtime/haskell/PGF/ByteCode.hs +++ b/src/runtime/haskell/PGF/ByteCode.hs @@ -2,7 +2,7 @@ module PGF.ByteCode(Literal(..), CodeLabel, Instr(..), IVal(..), TailInfo(..), ppLit, ppCode, ppInstr ) where - +import Prelude hiding ((<>)) -- GHC 8.4.1 clash with Text.PrettyPrint import PGF.CId import Text.PrettyPrint diff --git a/src/runtime/haskell/PGF/Macros.hs b/src/runtime/haskell/PGF/Macros.hs index de175616c..3fc7a5804 100644 --- a/src/runtime/haskell/PGF/Macros.hs +++ b/src/runtime/haskell/PGF/Macros.hs @@ -1,4 +1,5 @@ module PGF.Macros where +import Prelude hiding ((<>)) -- GHC 8.4.1 clash with Text.PrettyPrint import PGF.CId import PGF.Data diff --git a/src/runtime/haskell/PGF/Printer.hs b/src/runtime/haskell/PGF/Printer.hs index 43c270b13..07e94f866 100644 --- a/src/runtime/haskell/PGF/Printer.hs +++ b/src/runtime/haskell/PGF/Printer.hs @@ -1,5 +1,6 @@ {-# LANGUAGE FlexibleContexts #-} module PGF.Printer (ppPGF,ppCat,ppFId,ppFunId,ppSeqId,ppSeq,ppFun) where +import Prelude hiding ((<>)) -- GHC 8.4.1 clash with Text.PrettyPrint import PGF.CId import PGF.Data diff --git a/src/runtime/haskell/PGF/VisualizeTree.hs b/src/runtime/haskell/PGF/VisualizeTree.hs index 5d884fafe..520eb59c3 100644 --- a/src/runtime/haskell/PGF/VisualizeTree.hs +++ b/src/runtime/haskell/PGF/VisualizeTree.hs @@ -23,6 +23,7 @@ module PGF.VisualizeTree , gizaAlignment , conlls2latexDoc ) where +import Prelude hiding ((<>)) -- GHC 8.4.1 clash with Text.PrettyPrint import PGF.CId (wildCId,showCId,ppCId,mkCId) --CId,pCId, import PGF.Data