Skip to content

Commit

Permalink
Data.{Foldable1,Bifoldable1}.Compat
Browse files Browse the repository at this point in the history
On the `base-compat-batteries` side, it depends on `foldable1-classes-compat`
to backport `Foldable1` and `Bifoldable1` to old versions of `base`.

Addresses one part of #87.
  • Loading branch information
RyanGlScott committed Mar 10, 2023
1 parent a6d4dea commit e18c466
Show file tree
Hide file tree
Showing 14 changed files with 96 additions and 1 deletion.
4 changes: 4 additions & 0 deletions base-compat-batteries/CHANGES.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
- Require `OneTuple-0.4` or later on GHC 7.4+, as that is the first `OneTuple`
release to backport the `MkSolo` data constuctor for `Solo`. See
`Data.Tuple.Compat`.
- Introduce `Data.Foldable1.Compat` and `Data.Bifoldable1.Compat` modules,
which correspond to changes made in `base-4.18.0.0`. `base-compat-batteries`
uses the `foldable1-classes-compat` library to backport this code to older
versions of `base`.
- Depend on `bifunctor-classes-compat` to backport the `Bifunctor`,
`Bifoldable`, and `Bitraversable` classes instead of the
`bifunctors` library, which has more dependencies.
Expand Down
7 changes: 6 additions & 1 deletion base-compat-batteries/base-compat-batteries.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ library
contravariant >= 1.5 && < 1.6
if !impl(ghc >= 9.6)
build-depends:
OneTuple >= 0.4 && < 0.5
foldable1-classes-compat >= 0.1 && < 0.2,
OneTuple >= 0.4 && < 0.5
ghc-options:
-fno-warn-duplicate-exports
if impl(ghc >= 7.10)
Expand All @@ -91,13 +92,15 @@ library
Control.Monad.ST.Lazy.Unsafe.Compat
Control.Monad.ST.Unsafe.Compat
Data.Bifoldable.Compat
Data.Bifoldable1.Compat
Data.Bifunctor.Compat
Data.Bitraversable.Compat
Data.Bits.Compat
Data.Bool.Compat
Data.Complex.Compat
Data.Either.Compat
Data.Foldable.Compat
Data.Foldable1.Compat
Data.Function.Compat
Data.Functor.Compat
Data.Functor.Compose.Compat
Expand Down Expand Up @@ -155,13 +158,15 @@ library
Control.Monad.ST.Lazy.Unsafe.Compat.Repl.Batteries
Control.Monad.ST.Unsafe.Compat.Repl.Batteries
Data.Bifoldable.Compat.Repl.Batteries
Data.Bifoldable1.Compat.Repl.Batteries
Data.Bifunctor.Compat.Repl.Batteries
Data.Bitraversable.Compat.Repl.Batteries
Data.Bits.Compat.Repl.Batteries
Data.Bool.Compat.Repl.Batteries
Data.Complex.Compat.Repl.Batteries
Data.Either.Compat.Repl.Batteries
Data.Foldable.Compat.Repl.Batteries
Data.Foldable1.Compat.Repl.Batteries
Data.Function.Compat.Repl.Batteries
Data.Functor.Compat.Repl.Batteries
Data.Functor.Compose.Compat.Repl.Batteries
Expand Down
10 changes: 10 additions & 0 deletions base-compat-batteries/src/Data/Bifoldable1/Compat.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{-# LANGUAGE CPP, NoImplicitPrelude, PackageImports #-}
module Data.Bifoldable1.Compat (
module Base
) where

#if MIN_VERSION_base(4,18,0)
import "base-compat" Data.Bifoldable1.Compat as Base
#else
import "foldable1-classes-compat" Data.Bifoldable1 as Base
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{-# LANGUAGE PackageImports #-}
{-# OPTIONS_GHC -fno-warn-dodgy-exports -fno-warn-unused-imports #-}
-- | Reexports "Data.Bifoldable1.Compat"
-- from a globally unique namespace.
module Data.Bifoldable1.Compat.Repl.Batteries (
module Data.Bifoldable1.Compat
) where
import "this" Data.Bifoldable1.Compat
10 changes: 10 additions & 0 deletions base-compat-batteries/src/Data/Foldable1/Compat.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{-# LANGUAGE CPP, NoImplicitPrelude, PackageImports #-}
module Data.Foldable1.Compat (
module Base
) where

#if MIN_VERSION_base(4,18,0)
import "base-compat" Data.Foldable1.Compat as Base
#else
import "foldable1-classes-compat" Data.Foldable1 as Base
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{-# LANGUAGE PackageImports #-}
{-# OPTIONS_GHC -fno-warn-dodgy-exports -fno-warn-unused-imports #-}
-- | Reexports "Data.Foldable1.Compat"
-- from a globally unique namespace.
module Data.Foldable1.Compat.Repl.Batteries (
module Data.Foldable1.Compat
) where
import "this" Data.Foldable1.Compat
2 changes: 2 additions & 0 deletions base-compat-batteries/test/SafeHaskellSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ import Control.Monad.Compat ()
import Control.Monad.Fail.Compat ()
import Control.Monad.IO.Class.Compat ()
import Data.Bifoldable.Compat ()
import Data.Bifoldable1.Compat ()
import Data.Bifunctor.Compat ()
import Data.Bitraversable.Compat ()
import Data.Bits.Compat ()
import Data.Bool.Compat ()
import Data.Complex.Compat ()
import Data.Either.Compat ()
import Data.Foldable.Compat ()
import Data.Foldable1.Compat ()
import Data.Function.Compat ()
import Data.Functor.Compat ()
import Data.Functor.Compose.Compat ()
Expand Down
4 changes: 4 additions & 0 deletions base-compat/CHANGES.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
- Backport `heqT` to `Data.Typeable.Compat`. Note that `heqT` is only defined
when building with `base-4.10` or later, as that is the first version of
`base` to provide the primitives needed to define `heqT`.
- Introduce `Data.Foldable1.Compat` and `Data.Bifoldable1.Compat` modules,
which correspond to changes made in `base-4.18.0.0`. You may consider using
`base-compat-batteries` instead if you want increase the range of `base`
versions that are supported.

## Changes in 0.12.2 [2022.08.11]
- Sync with `base-4.17`/GHC 9.4
Expand Down
4 changes: 4 additions & 0 deletions base-compat/README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,10 @@ on, paired with the things that each library backports:
* [`fail`](http://hackage.haskell.org/package/fail)
for the [`MonadFail`](http://hackage.haskell.org/package/base-4.9.0.0/docs/Control-Monad-Fail.html#t:MonadFail)
type class, introduced in `base-4.9.0.0`
* [`foldable1-classes-compat`](https://hackage.haskell.org/package/foldable1-classes-compat)
for the [`Foldable1`](https://hackage.haskell.org/package/foldable1-classes-compat-0.1/docs/Data-Foldable1.html#t:Foldable1)
and [`Bifoldable1`](https://hackage.haskell.org/package/foldable1-classes-compat-0.1/docs/Data-Bifoldable1.html#t:Bifoldable1)
type classes, introduced in `base-4.18.0.0`
* [`nats`](http://hackage.haskell.org/package/nats)
for the [`Natural`](http://hackage.haskell.org/package/base-4.8.0.0/docs/Numeric-Natural.html)
data type, introduced in `base-4.8.0.0`
Expand Down
4 changes: 4 additions & 0 deletions base-compat/base-compat.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,15 @@ library
Control.Monad.ST.Lazy.Unsafe.Compat
Control.Monad.ST.Unsafe.Compat
Data.Bifoldable.Compat
Data.Bifoldable1.Compat
Data.Bifunctor.Compat
Data.Bitraversable.Compat
Data.Bits.Compat
Data.Bool.Compat
Data.Complex.Compat
Data.Either.Compat
Data.Foldable.Compat
Data.Foldable1.Compat
Data.Function.Compat
Data.Functor.Compat
Data.Functor.Compose.Compat
Expand Down Expand Up @@ -142,13 +144,15 @@ library
Control.Monad.ST.Lazy.Unsafe.Compat.Repl
Control.Monad.ST.Unsafe.Compat.Repl
Data.Bifoldable.Compat.Repl
Data.Bifoldable1.Compat.Repl
Data.Bifunctor.Compat.Repl
Data.Bitraversable.Compat.Repl
Data.Bits.Compat.Repl
Data.Bool.Compat.Repl
Data.Complex.Compat.Repl
Data.Either.Compat.Repl
Data.Foldable.Compat.Repl
Data.Foldable1.Compat.Repl
Data.Function.Compat.Repl
Data.Functor.Compat.Repl
Data.Functor.Compose.Compat.Repl
Expand Down
10 changes: 10 additions & 0 deletions base-compat/src/Data/Bifoldable1/Compat.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{-# LANGUAGE CPP, NoImplicitPrelude #-}
module Data.Bifoldable1.Compat (
#if MIN_VERSION_base(4,18,0)
module Base
#endif
) where

#if MIN_VERSION_base(4,18,0)
import Data.Bifoldable1 as Base
#endif
8 changes: 8 additions & 0 deletions base-compat/src/Data/Bifoldable1/Compat/Repl.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{-# LANGUAGE PackageImports #-}
{-# OPTIONS_GHC -fno-warn-dodgy-exports -fno-warn-unused-imports #-}
-- | Reexports "Data.Bifoldable1.Compat"
-- from a globally unique namespace.
module Data.Bifoldable1.Compat.Repl (
module Data.Bifoldable1.Compat
) where
import "this" Data.Bifoldable1.Compat
10 changes: 10 additions & 0 deletions base-compat/src/Data/Foldable1/Compat.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{-# LANGUAGE CPP, NoImplicitPrelude #-}
module Data.Foldable1.Compat (
#if MIN_VERSION_base(4,18,0)
module Base
#endif
) where

#if MIN_VERSION_base(4,18,0)
import Data.Foldable1 as Base
#endif
8 changes: 8 additions & 0 deletions base-compat/src/Data/Foldable1/Compat/Repl.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{-# LANGUAGE PackageImports #-}
{-# OPTIONS_GHC -fno-warn-dodgy-exports -fno-warn-unused-imports #-}
-- | Reexports "Data.Foldable1.Compat"
-- from a globally unique namespace.
module Data.Foldable1.Compat.Repl (
module Data.Foldable1.Compat
) where
import "this" Data.Foldable1.Compat

0 comments on commit e18c466

Please sign in to comment.