base-orphans 0.8.8.2 → 0.9.0
raw patch · 4 files changed
+44/−15 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Data.Orphans: instance (GHC.Enum.Enum a, GHC.Enum.Bounded a, GHC.Classes.Eq a) => GHC.Enum.Enum (Data.Ord.Down a)
Files
- CHANGES.markdown +14/−7
- README.markdown +1/−1
- base-orphans.cabal +3/−3
- src/Data/Orphans.hs +26/−4
CHANGES.markdown view
@@ -1,10 +1,17 @@-## Changes in 0.8.8.2 [2023.03.07]- - Fix GHC 9.2.1 build error that was accidentally introduced in- `base-orphans-0.8.8`.--## Changes in 0.8.8.1 [2023.03.05]- - Fix GHC 9.4 build error that was accidentally introduced in- `base-orphans-0.8.8`.+## 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+ the values of `minBound` and `maxBound` for the underlying type. This+ change has now been propagated to `base-orphans`.+ * The `Enum` instance for `Down` was removed in `base-4.15.0.0`, but a+ different version of the instance was added back in `base-4.18.0.0`, where+ `succ` and `pred` are swapped. We have changed the backported version of+ this instance in `base-orphans` to match the behavior of the instance+ added in `base-4.18.0.0`.+ * The `Integral` instance for `Down` was removed from `base` entirely in+ `base-4.15.0.0`. We have finally removed it from `base-orphans` in this+ release, as it actively makes it more difficult to define the+ aforementioned `Enum` instance. ## Changes in 0.8.8 [2023.03.05] - Backport new instances from GHC 9.6.1/`base-4.18.0.0`:
README.markdown view
@@ -36,7 +36,7 @@ * `Alternative`, `Eq`, `Ord`, `Read`, `Show`, `Foldable`, and `Traversable` instances for `ZipList` * `Applicative` instance for `K1` from `GHC.Generics` * `Applicative`, `Bits`, `Bounded`, `Data`, `Enum`, `Eq1`, `FiniteBits`,- `Floating`, `Foldable`, `Fractional`, `Functor`, `Integral`, `Ix`, `Ord1`,+ `Floating`, `Foldable`, `Fractional`, `Functor`, `Ix`, `Ord1`, `Monad`, `MonadFix`, `MonadZip`, `Monoid`, `Num`, `Read`, `Read1`, `Real`, `RealFloat`, `RealFrac`, `Semigroup`, `Show`, `Show1`, `Storable`, and `Traversable` instances for `Down`
base-orphans.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 5f8726da7da713fa7b7a95dea492501a6762a25a36aebbd6bb8931e0d0324660+-- hash: 7aa19d6f2d3a7409ee405d67a21b8edb902103b703a6f241f2b5e8e219f70a87 name: base-orphans-version: 0.8.8.2+version: 0.9.0 synopsis: Backwards-compatible orphan instances for base description: @base-orphans@ defines orphan instances that mimic instances available in later versions of @base@ to a wider (older) range of compilers.@@ -36,7 +36,7 @@ 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.1 , GHC == 9.2.7 , GHC == 9.4.4 , GHC == 9.6.1+ 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.7 , GHC == 9.4.4 , GHC == 9.6.1 extra-source-files: CHANGES.markdown README.markdown
src/Data/Orphans.hs view
@@ -94,7 +94,7 @@ # endif #endif -#if !(MIN_VERSION_base(4,16,1)) || (MIN_VERSION_base(4,17,0) && !(MIN_VERSION_base(4,18,0)))+#if !(MIN_VERSION_base(4,18,0)) import Data.Orphans.Prelude #endif @@ -1188,12 +1188,14 @@ Kleisli f `mplus` Kleisli g = Kleisli $ \x -> f x `mplus` g x {-# INLINE mplus #-} +-- | Swaps @'minBound'@ and @'maxBound'@ of the underlying type.+instance Bounded a => Bounded (Down a) where+ minBound = Down maxBound+ maxBound = Down minBound+ deriving instance Bits a => Bits (Down a)-deriving instance Bounded a => Bounded (Down a)-deriving instance Enum a => Enum (Down a) deriving instance Floating a => Floating (Down a) deriving instance Fractional a => Fractional (Down a)-deriving instance Integral a => Integral (Down a) deriving instance Ix a => Ix (Down a) deriving instance Real a => Real (Down a) deriving instance RealFrac a => RealFrac (Down a)@@ -1973,6 +1975,26 @@ fmap fun (a, b, c, d, e, f) = (a, b, c, d, e, fun f) instance Functor ((,,,,,,) a b c d e f) where fmap fun (a, b, c, d, e, f, g) = (a, b, c, d, e, f, fun g)++# if !(MIN_VERSION_base(4,14,0)) || MIN_VERSION_base(4,15,0)+-- | Swaps @'succ'@ and @'pred'@ of the underlying type.+instance (Enum a, Bounded a, Eq a) => Enum (Down a) where+ succ = fmap pred+ pred = fmap succ++ -- Here we use the fact that 'comparing (complement @Int)' behaves+ -- as an order-swapping `compare @Int`.+ fromEnum (Down x) = complement $ fromEnum x+ toEnum = Down . toEnum . complement++ enumFrom (Down x)+ | x == minBound+ = [Down x] -- We can't rely on 'enumFromThen _ (pred @a minBound)` behaving nicely,+ -- since 'enumFromThen _' might be strict and 'pred minBound' might throw+ | otherwise+ = coerce $ enumFromThen x (pred x)+ enumFromThen (Down x) (Down y) = coerce $ enumFromThen x y+# endif # if MIN_VERSION_base(4,17,0) instance (Generic1 f, Eq (Rep1 f a)) => Eq (Generically1 f a) where