From 3ffde78fb8161ac6129adbc3ccf97dc2771786b7 Mon Sep 17 00:00:00 2001 From: Andreas Abel Date: Fri, 24 Sep 2021 14:50:48 +0200 Subject: [PATCH 1/2] Fix #199: support GHC 9.2 (base 4.16) by putting Option under #if In base-4.16, Option was removed. Bump version to 1.0.15.3. --- mono-traversable/ChangeLog.md | 5 +++++ mono-traversable/package.yaml | 2 +- mono-traversable/src/Data/MonoTraversable.hs | 21 ++++++++++++++++++-- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/mono-traversable/ChangeLog.md b/mono-traversable/ChangeLog.md index 4be68d79..4ad6f96d 100644 --- a/mono-traversable/ChangeLog.md +++ b/mono-traversable/ChangeLog.md @@ -1,5 +1,10 @@ # ChangeLog for mono-traversable +## 1.0.15.3 + +* Compile with GHC 9.2 (`Option` removed from `base-4.16`) + [#199](https://github.com/snoyberg/mono-traversable/issues/199) + ## 1.0.15.2 * Support transformers 0.6.0.0 [#196](https://github.com/snoyberg/mono-traversable/issues/196) diff --git a/mono-traversable/package.yaml b/mono-traversable/package.yaml index e8e26a98..3992213c 100644 --- a/mono-traversable/package.yaml +++ b/mono-traversable/package.yaml @@ -1,5 +1,5 @@ name: mono-traversable -version: 1.0.15.2 +version: 1.0.15.3 synopsis: Type classes for mapping, folding, and traversing monomorphic containers description: Please see the README at category: Data diff --git a/mono-traversable/src/Data/MonoTraversable.hs b/mono-traversable/src/Data/MonoTraversable.hs index eb09e480..460d2456 100644 --- a/mono-traversable/src/Data/MonoTraversable.hs +++ b/mono-traversable/src/Data/MonoTraversable.hs @@ -90,7 +90,14 @@ import qualified Data.Vector as V import qualified Data.Vector.Unboxed as U import qualified Data.Vector.Storable as VS import qualified Data.IntSet as IntSet -import Data.Semigroup (Semigroup, Option (..), Arg) +import Data.Semigroup + ( Semigroup +-- Option has been removed in base-4.16 (GHC 9.2) +#if !MIN_VERSION_base(4,16,0) + , Option (..) +#endif + , Arg + ) import qualified Data.ByteString.Unsafe as SU import Control.Monad.Trans.Identity (IdentityT) @@ -111,7 +118,9 @@ type instance Element (ViewL a) = a type instance Element (ViewR a) = a type instance Element (IntMap a) = a type instance Element IntSet = Int +#if !MIN_VERSION_base(4,16,0) type instance Element (Option a) = a +#endif type instance Element (NonEmpty a) = a type instance Element (Identity a) = a type instance Element (r -> a) = a @@ -184,7 +193,9 @@ instance MonoFunctor (Seq a) instance MonoFunctor (ViewL a) instance MonoFunctor (ViewR a) instance MonoFunctor (IntMap a) +#if !MIN_VERSION_base(4,16,0) instance MonoFunctor (Option a) +#endif instance MonoFunctor (NonEmpty a) instance MonoFunctor (Identity a) instance MonoFunctor (r -> a) @@ -352,7 +363,7 @@ class MonoFoldable mono where -- /See 'Data.NonNull.ofoldMap1' from "Data.NonNull" for a total version of this function./ ofoldMap1Ex :: Semigroup m => (Element mono -> m) -> mono -> m ofoldMap1Ex f = fromMaybe (Prelude.error "Data.MonoTraversable.ofoldMap1Ex") - . getOption . ofoldMap (Option . Just . f) + . ofoldMap (Just . f) -- | Right-associative fold of a monomorphic container with no base element. -- @@ -630,7 +641,9 @@ instance MonoFoldable (Seq a) where instance MonoFoldable (ViewL a) instance MonoFoldable (ViewR a) instance MonoFoldable (IntMap a) +#if !MIN_VERSION_base(4,16,0) instance MonoFoldable (Option a) +#endif instance MonoFoldable (NonEmpty a) instance MonoFoldable (Identity a) instance MonoFoldable (Map k v) where @@ -1009,7 +1022,9 @@ instance MonoTraversable (Seq a) instance MonoTraversable (ViewL a) instance MonoTraversable (ViewR a) instance MonoTraversable (IntMap a) +#if !MIN_VERSION_base(4,16,0) instance MonoTraversable (Option a) +#endif instance MonoTraversable (NonEmpty a) instance MonoTraversable (Identity a) instance MonoTraversable (Map k v) @@ -1135,7 +1150,9 @@ instance MonoPointed TL.Text where -- Applicative instance MonoPointed [a] instance MonoPointed (Maybe a) +#if !MIN_VERSION_base(4,16,0) instance MonoPointed (Option a) +#endif instance MonoPointed (NonEmpty a) instance MonoPointed (Identity a) instance MonoPointed (Vector a) From d0d1dc3a469f6ee7daf9974d1c404325a8a150d7 Mon Sep 17 00:00:00 2001 From: Andreas Abel Date: Fri, 24 Sep 2021 15:01:27 +0200 Subject: [PATCH 2/2] Fix some import warnings --- mono-traversable/src/Data/Containers.hs | 1 - mono-traversable/src/Data/MonoTraversable.hs | 2 +- mono-traversable/src/Data/MonoTraversable/Unprefixed.hs | 1 - mono-traversable/src/Data/NonNull.hs | 1 - 4 files changed, 1 insertion(+), 4 deletions(-) diff --git a/mono-traversable/src/Data/Containers.hs b/mono-traversable/src/Data/Containers.hs index 49f9cca0..6b4ac042 100644 --- a/mono-traversable/src/Data/Containers.hs +++ b/mono-traversable/src/Data/Containers.hs @@ -16,7 +16,6 @@ import Data.Hashable (Hashable) import qualified Data.Set as Set import qualified Data.HashSet as HashSet import Data.Monoid (Monoid (..)) -import Data.Semigroup (Semigroup) import Data.MonoTraversable (MonoFunctor(..), MonoFoldable, MonoTraversable, Element, GrowingAppend, ofoldl', otoList) import Data.Function (on) import qualified Data.List as List diff --git a/mono-traversable/src/Data/MonoTraversable.hs b/mono-traversable/src/Data/MonoTraversable.hs index 460d2456..a002a8c5 100644 --- a/mono-traversable/src/Data/MonoTraversable.hs +++ b/mono-traversable/src/Data/MonoTraversable.hs @@ -44,7 +44,7 @@ import Data.Traversable import Data.Word (Word8) import Data.Int (Int, Int64) import GHC.Exts (build) -import GHC.Generics ((:.:), (:*:), (:+:)(..), K1(..), M1(..), Par1(..), Rec1(..), U1(..), V1(..)) +import GHC.Generics ((:.:), (:*:), (:+:)(..), K1(..), M1(..), Par1(..), Rec1(..), U1(..), V1) import Prelude (Bool (..), const, Char, flip, IO, Maybe (..), Either (..), (+), Integral, Ordering (..), compare, fromIntegral, Num, (>=), (==), seq, otherwise, Eq, Ord, (-), (*)) diff --git a/mono-traversable/src/Data/MonoTraversable/Unprefixed.hs b/mono-traversable/src/Data/MonoTraversable/Unprefixed.hs index e3f49801..326ee27d 100644 --- a/mono-traversable/src/Data/MonoTraversable/Unprefixed.hs +++ b/mono-traversable/src/Data/MonoTraversable/Unprefixed.hs @@ -14,7 +14,6 @@ module Data.MonoTraversable.Unprefixed where import Data.Int (Int64) import Data.MonoTraversable -import Data.Semigroup (Semigroup) import Data.Monoid (Monoid) import Control.Applicative (Applicative) diff --git a/mono-traversable/src/Data/NonNull.hs b/mono-traversable/src/Data/NonNull.hs index 337641b3..87c6a419 100644 --- a/mono-traversable/src/Data/NonNull.hs +++ b/mono-traversable/src/Data/NonNull.hs @@ -49,7 +49,6 @@ import qualified Data.List.NonEmpty as NE import Data.Maybe (fromMaybe) import Data.MonoTraversable import Data.Sequences -import Data.Semigroup (Semigroup (..)) import Control.Monad.Trans.State.Strict (evalState, state) data NullError = NullError String deriving (Show, Typeable)