diff --git a/CHANGES.markdown b/CHANGES.markdown index ae69494..0f399e6 100644 --- a/CHANGES.markdown +++ b/CHANGES.markdown @@ -1,3 +1,7 @@ +## Changes in next [????.??.??] + - Backport new instances from GHC 9.10/`base-4.20`: + * `Fractional`, `RealFrac`, `Floating`, and `RealFloat` instances for `Compose` + ## Changes in 0.9.1 [2023.10.11] - Backport new instances from GHC 9.8/`base-4.19`: * `Eq` and `Ord` instances for `SChar`, `SNat`, and `SSymbol` diff --git a/README.markdown b/README.markdown index a7ed79a..82621b0 100644 --- a/README.markdown +++ b/README.markdown @@ -60,7 +60,7 @@ To use `base-orphans`, simply `import Data.Orphans ()`. * `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` + * `Enum`, `Bounded`, `Num`, `Real`, `Integral`, `Fractional`, `RealFrac`, `Floating`, and `RealFloat` instances for `Compose` * `Foldable` instance for `Either`, `(,)` and `Const` * `Foldable` and `Traversable` instances for `Alt` from `Data.Monoid` * `Functor`, `Applicative`, and `Monad` instances for @@ -106,6 +106,7 @@ To use `base-orphans`, simply `import Data.Orphans ()`. ## Supported versions of GHC/`base` + * `ghc-9.10.*` / `base-4.20.*` * `ghc-9.8.*` / `base-4.19.*` * `ghc-9.6.*` / `base-4.18.*` * `ghc-9.4.*` / `base-4.17.*` diff --git a/src/Data/Orphans.hs b/src/Data/Orphans.hs index eee3349..94b7b7c 100644 --- a/src/Data/Orphans.hs +++ b/src/Data/Orphans.hs @@ -94,7 +94,7 @@ import GHC.ConsoleHandler as Console # endif #endif -#if !(MIN_VERSION_base(4,19,0)) +#if !(MIN_VERSION_base(4,20,0)) import Data.Orphans.Prelude #endif @@ -2050,6 +2050,25 @@ instance Ord (SSymbol s) where # endif #endif +#if !(MIN_VERSION_base(4,20,0)) +# if MIN_VERSION_base(4,9,0) +deriving instance Fractional (f (g a)) => Fractional (Compose f g a) +deriving instance Floating (f (g a)) => Floating (Compose f g a) + +-- RealFrac and RealFloat both have Ord as a superclass. For the reasons stated +-- above (near the Real/Integral instances for Compose), these +-- RealFrace/RealFloat instances are slightly more complicated for older +-- versions of base. +# if MIN_VERSION_base(4,18,0) +deriving instance RealFrac (f (g a)) => RealFrac (Compose f g a) +deriving instance RealFloat (f (g a)) => RealFloat (Compose f g a) +# else +deriving instance (RealFrac (f (g a)), Ord1 f, Ord1 g, Ord a) => RealFrac (Compose f g a) +deriving instance (RealFloat (f (g a)), Ord1 f, Ord1 g, Ord a) => RealFloat (Compose f g a) +# endif +# endif +#endif + #if __GLASGOW_HASKELL__ < 710 deriving instance Typeable All deriving instance Typeable AnnotationWrapper diff --git a/src/Data/Orphans/Prelude.hs b/src/Data/Orphans/Prelude.hs index 13e011a..571d543 100644 --- a/src/Data/Orphans/Prelude.hs +++ b/src/Data/Orphans/Prelude.hs @@ -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,19,0) +#if MIN_VERSION_base(4,20,0) () where #else ( module OrphansPrelude