From 68ec785b16182c4a49bd1a816c22bad718da21df Mon Sep 17 00:00:00 2001 From: Jens Petersen Date: Sat, 3 Jul 2021 11:12:25 +0800 Subject: [PATCH 1/4] stack: update to lts-17.15 --- stack.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stack.yaml b/stack.yaml index d43c62d..e8a8edd 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,4 +1,4 @@ -resolver: lts-17.5 +resolver: lts-17.15 packages: - . extra-deps: [] From 9a6defa981400955bf1a116c7f4eee289663b531 Mon Sep 17 00:00:00 2001 From: Jens Petersen Date: Sat, 3 Jul 2021 11:45:27 +0800 Subject: [PATCH 2/4] seems MonadFail only needs to be imported for ghc-8.6 (base-4.12) silences the redundant import warnings on ghc >= 8.8 --- src/Control/Monad/Trans/OptionParser.hs | 6 +++++- src/Control/Monad/Trans/State/Persistent.hs | 2 +- src/Control/Monad/Trans/Uncertain.hs | 6 +++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Control/Monad/Trans/OptionParser.hs b/src/Control/Monad/Trans/OptionParser.hs index af71987..f0ea04b 100644 --- a/src/Control/Monad/Trans/OptionParser.hs +++ b/src/Control/Monad/Trans/OptionParser.hs @@ -7,7 +7,11 @@ import Prelude hiding (fail) import Control.Monad hiding (fail) #if MIN_VERSION_base(4,12,0) -import Control.Monad.Fail (MonadFail, fail) +import Control.Monad.Fail ( +#if !MIN_VERSION_base(4,13,0) + MonadFail, +#endif + fail) #else import Prelude (fail) #endif diff --git a/src/Control/Monad/Trans/State/Persistent.hs b/src/Control/Monad/Trans/State/Persistent.hs index dcaf59f..0c89897 100644 --- a/src/Control/Monad/Trans/State/Persistent.hs +++ b/src/Control/Monad/Trans/State/Persistent.hs @@ -4,7 +4,7 @@ module Control.Monad.Trans.State.Persistent where import Control.Applicative import Control.Monad -#if MIN_VERSION_base(4,12,0) +#if MIN_VERSION_base(4,12,0) && !MIN_VERSION_base(4,13,0) import Control.Monad.Fail (MonadFail) #endif import Control.Monad.IO.Class diff --git a/src/Control/Monad/Trans/Uncertain.hs b/src/Control/Monad/Trans/Uncertain.hs index 0c8c675..0b461bb 100644 --- a/src/Control/Monad/Trans/Uncertain.hs +++ b/src/Control/Monad/Trans/Uncertain.hs @@ -5,7 +5,11 @@ module Control.Monad.Trans.Uncertain where import Prelude hiding (fail) #if MIN_VERSION_base(4,12,0) -import Control.Monad.Fail (MonadFail, fail) +import Control.Monad.Fail ( +#if !MIN_VERSION_base(4,13,0) + MonadFail, +#endif + fail) #else import Prelude (fail) #endif From 859f13eec1dcfbf5fbd52a5ad8beb4a5268e95a3 Mon Sep 17 00:00:00 2001 From: Jens Petersen Date: Sat, 3 Jul 2021 13:44:17 +0800 Subject: [PATCH 3/4] TestUtils: silence <$> import warning for base >= 4.8 --- tests/System/Console/Hawk/TestUtils.hs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/System/Console/Hawk/TestUtils.hs b/tests/System/Console/Hawk/TestUtils.hs index bb114a1..552fed9 100644 --- a/tests/System/Console/Hawk/TestUtils.hs +++ b/tests/System/Console/Hawk/TestUtils.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE CPP #-} + -- Copyright 2013 Mario Pastorelli (pastorelli.mario@gmail.com) Samuel GĂ©lineau (gelisam@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,8 +16,10 @@ module System.Console.Hawk.TestUtils where +#if !MIN_VERSION_base(4,8,0) import Control.Applicative ( (<$>) ) +#endif import Control.Exception ( bracket_ ) import Data.List From 10cc5ef882fdd79852f3a0e17faa9e7b5d112e7d Mon Sep 17 00:00:00 2001 From: Jens Petersen Date: Sat, 3 Jul 2021 13:45:53 +0800 Subject: [PATCH 4/4] Location: Semigroup deprecated Option in ghc-9.0 It will be removed in 9.2, so just use Maybe but it is still needed for base < 4.11 --- src/Language/Haskell/Exts/Location.hs | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/Language/Haskell/Exts/Location.hs b/src/Language/Haskell/Exts/Location.hs index 914e941..5601cad 100644 --- a/src/Language/Haskell/Exts/Location.hs +++ b/src/Language/Haskell/Exts/Location.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE CPP #-} + -- | Easier access to haskell-src-exts's SrcLoc values. module Language.Haskell.Exts.Location where @@ -14,11 +16,23 @@ import Language.Haskell.Exts.Syntax -- -- The location only indicates the beginning of a range, because that's what -- haskell-src-exts provides. -type Located a = Writer (Option (Min SrcLoc)) a +type Located a = Writer ( +#if MIN_VERSION_base(4,11,0) + Maybe +#else + Option +#endif + (Min SrcLoc)) a located :: SrcLoc -> Located () -located srcLoc | srcLoc == noLoc = tell $ Option $ Nothing - | otherwise = tell $ Option $ Just $ Min srcLoc +located srcLoc = + tell $ +#if !MIN_VERSION_base(4,11,0) + Option $ +#endif + if srcLoc == noLoc + then Nothing + else Just $ Min srcLoc annotated :: (Annotated ast, SrcInfo si) => ast si -> Located (ast si) annotated x = do @@ -28,4 +42,8 @@ annotated x = do runLocated :: Located a -> (a, Maybe SrcLoc) runLocated = go . runWriter where - go (x, p) = (x, fmap getMin $ getOption $ p) + go (x, p) = (x, fmap getMin $ +#if !MIN_VERSION_base(4,11,0) + getOption +#endif + p)