Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport instances introduced in base-4.19 #69

Merged
merged 2 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions .github/workflows/haskell-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
#
# For more information, see https://github.com/haskell-CI/haskell-ci
#
# version: 0.16.6
# version: 0.17.20231010
#
# REGENDATA ("0.16.6",["github","--config=cabal.haskell-ci","cabal.project"])
# REGENDATA ("0.17.20231010",["github","--config=cabal.haskell-ci","cabal.project"])
#
name: Haskell-CI
on:
Expand All @@ -28,6 +28,11 @@ jobs:
strategy:
matrix:
include:
- compiler: ghc-9.8.1
compilerKind: ghc
compilerVersion: 9.8.1
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.6.2
compilerKind: ghc
compilerVersion: 9.6.2
Expand Down Expand Up @@ -116,7 +121,7 @@ jobs:
apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5
if [ "${{ matrix.setup-method }}" = ghcup ]; then
mkdir -p "$HOME/.ghcup/bin"
curl -sL https://downloads.haskell.org/ghcup/0.1.19.2/x86_64-linux-ghcup-0.1.19.2 > "$HOME/.ghcup/bin/ghcup"
curl -sL https://downloads.haskell.org/ghcup/0.1.19.5/x86_64-linux-ghcup-0.1.19.5 > "$HOME/.ghcup/bin/ghcup"
chmod a+x "$HOME/.ghcup/bin/ghcup"
"$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false)
"$HOME/.ghcup/bin/ghcup" install cabal 3.10.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
Expand All @@ -125,7 +130,7 @@ jobs:
apt-get update
apt-get install -y "$HCNAME"
mkdir -p "$HOME/.ghcup/bin"
curl -sL https://downloads.haskell.org/ghcup/0.1.19.2/x86_64-linux-ghcup-0.1.19.2 > "$HOME/.ghcup/bin/ghcup"
curl -sL https://downloads.haskell.org/ghcup/0.1.19.5/x86_64-linux-ghcup-0.1.19.5 > "$HOME/.ghcup/bin/ghcup"
chmod a+x "$HOME/.ghcup/bin/ghcup"
"$HOME/.ghcup/bin/ghcup" install cabal 3.10.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
fi
Expand All @@ -141,10 +146,12 @@ jobs:
echo "CABAL_CONFIG=$HOME/.cabal/config" >> "$GITHUB_ENV"
HCDIR=/opt/$HCKIND/$HCVER
if [ "${{ matrix.setup-method }}" = ghcup ]; then
HC=$HOME/.ghcup/bin/$HCKIND-$HCVER
HC=$("$HOME/.ghcup/bin/ghcup" whereis ghc "$HCVER")
HCPKG=$(echo "$HC" | sed 's#ghc$#ghc-pkg#')
HADDOCK=$(echo "$HC" | sed 's#ghc$#haddock#')
echo "HC=$HC" >> "$GITHUB_ENV"
echo "HCPKG=$HOME/.ghcup/bin/$HCKIND-pkg-$HCVER" >> "$GITHUB_ENV"
echo "HADDOCK=$HOME/.ghcup/bin/haddock-$HCVER" >> "$GITHUB_ENV"
echo "HCPKG=$HCPKG" >> "$GITHUB_ENV"
echo "HADDOCK=$HADDOCK" >> "$GITHUB_ENV"
echo "CABAL=$HOME/.ghcup/bin/cabal-3.10.1.0 -vnormal+nowrap" >> "$GITHUB_ENV"
else
HC=$HCDIR/bin/$HCKIND
Expand Down
5 changes: 5 additions & 0 deletions CHANGES.markdown
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## Changes in next [????.??.??]
- Backport new instances from GHC 9.8/`base-4.19`:
* `Eq` and `Ord` instances for `SChar`, `SNat`, and `SSymbol`
* `Enum`, `Bounded`, `Num`, `Real`, and `Integral` instances for `Compose`

## Changes in 0.9.0 [2023.03.05]
- Adapt to recent changes to `Down` instances:
* The `Bounded` instance for `Down` was changed in `base-4.15.0.0` to swap
Expand Down
3 changes: 3 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ To use `base-orphans`, simply `import Data.Orphans ()`.
* `Eq`, `Ord`, `Read`, and `Show` instances for data types in `GHC.Generics`
* `Eq`, `Ord`, `Bounded`, `Enum`, and `Ix` instances for `Solo`
* `Eq` and `Ord` instances for `Generically1`
* `Eq` and `Ord` instances for `SChar`, `SNat`, and `SSymbol`
* `Eq1`, `Read1`, and `Show1` instances for `Complex`
* `Eq1`, `Ord1`, `Read1`, and `Show1` instances for `NonEmpty`
* `Enum`, `Bounded`, `Num`, `Real`, and `Integral` instances for `Compose`
* `Foldable` instance for `Either`, `(,)` and `Const`
* `Foldable` and `Traversable` instances for `Alt` from `Data.Monoid`
* `Functor`, `Applicative`, and `Monad` instances for
Expand Down Expand Up @@ -104,6 +106,7 @@ To use `base-orphans`, simply `import Data.Orphans ()`.

## Supported versions of GHC/`base`

* `ghc-9.8.*` / `base-4.19.*`
* `ghc-9.6.*` / `base-4.18.*`
* `ghc-9.4.*` / `base-4.17.*`
* `ghc-9.2.*` / `base-4.16.*`
Expand Down
4 changes: 2 additions & 2 deletions base-orphans.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cabal-version: 1.12
--
-- see: https://github.com/sol/hpack
--
-- hash: da3031e39b0331888e834742d92bbce742fe2f0f3f5e1f32fe3668cc0677a5f5
-- hash: 965bea20bba9f60facd602dae11eb6a09f80edf0af89cc4449270263e67ae367

name: base-orphans
version: 0.9.0
Expand Down Expand Up @@ -36,7 +36,7 @@ license: MIT
license-file: LICENSE
build-type: Simple
tested-with:
GHC == 7.0.4 , GHC == 7.2.2 , GHC == 7.4.2 , GHC == 7.6.3 , GHC == 7.8.4 , GHC == 7.10.3 , GHC == 8.0.2 , GHC == 8.2.2 , GHC == 8.4.4 , GHC == 8.6.5 , GHC == 8.8.4 , GHC == 8.10.7 , GHC == 9.0.2 , GHC == 9.2.8 , GHC == 9.4.5 , GHC == 9.6.2
GHC == 7.0.4 , GHC == 7.2.2 , GHC == 7.4.2 , GHC == 7.6.3 , GHC == 7.8.4 , GHC == 7.10.3 , GHC == 8.0.2 , GHC == 8.2.2 , GHC == 8.4.4 , GHC == 8.6.5 , GHC == 8.8.4 , GHC == 8.10.7 , GHC == 9.0.2 , GHC == 9.2.8 , GHC == 9.4.5 , GHC == 9.6.2 , GHC == 9.8.1
extra-source-files:
CHANGES.markdown
README.markdown
Expand Down
1 change: 1 addition & 0 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ tested-with: GHC == 7.0.4
, GHC == 9.2.8
, GHC == 9.4.5
, GHC == 9.6.2
, GHC == 9.8.1

extra-source-files:
- CHANGES.markdown
Expand Down
46 changes: 45 additions & 1 deletion src/Data/Orphans.hs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ import GHC.ConsoleHandler as Console
# endif
#endif

#if !(MIN_VERSION_base(4,18,0))
#if !(MIN_VERSION_base(4,19,0))
import Data.Orphans.Prelude
#endif

Expand Down Expand Up @@ -2006,6 +2006,50 @@ instance (Generic1 f, Ord (Rep1 f a)) => Ord (Generically1 f a) where
# endif
#endif

#if !(MIN_VERSION_base(4,19,0))
# if MIN_VERSION_base(4,9,0)
deriving instance Enum (f (g a)) => Enum (Compose f g a)
deriving instance Bounded (f (g a)) => Bounded (Compose f g a)
deriving instance Num (f (g a)) => Num (Compose f g a)

-- In base-4.18.0.0, the Ord instance for Compose was simplified to:
--
-- instance Ord (f (g a)) => Ord (Compose f g a)
--
-- Before that, the Ord instance was defined as:
--
-- instance (Ord1 f, Ord1 g, Ord a) => Ord (Compose f g a)
--
-- This makes deriving Real and Integral instances slightly more complicated for
-- these older versions of base, as there are no Real1 or Integral1 classes. We
-- opt for making the instance contexts more complicated instead.
# if MIN_VERSION_base(4,18,0)
deriving instance Real (f (g a)) => Real (Compose f g a)
deriving instance Integral (f (g a)) => Integral (Compose f g a)
# else
deriving instance (Real (f (g a)), Ord1 f, Ord1 g, Ord a) => Real (Compose f g a)
deriving instance (Integral (f (g a)), Ord1 f, Ord1 g, Ord a) => Integral (Compose f g a)
# endif
# endif

# if MIN_VERSION_base(4,18,0)
instance Eq (SChar c) where
_ == _ = True
instance Ord (SChar c) where
compare _ _ = EQ

instance Eq (SNat n) where
_ == _ = True
instance Ord (SNat n) where
compare _ _ = EQ

instance Eq (SSymbol s) where
_ == _ = True
instance Ord (SSymbol s) where
compare _ _ = EQ
# endif
#endif

#if __GLASGOW_HASKELL__ < 710
deriving instance Typeable All
deriving instance Typeable AnnotationWrapper
Expand Down
2 changes: 1 addition & 1 deletion src/Data/Orphans/Prelude.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ This makes it much easier to be -Wall-compliant.
Note that this module does not export any modules that could introduce name clashes.
-}
module Data.Orphans.Prelude
#if MIN_VERSION_base(4,18,0)
#if MIN_VERSION_base(4,19,0)
() where
#else
( module OrphansPrelude
Expand Down