diff options
author | Oleg Grenrus <oleg.grenrus@iki.fi> | 2020-06-10 21:05:12 +0300 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-06-25 03:54:46 -0400 |
commit | 67a86b4d4d21954bae7aaddec7617228025a8270 (patch) | |
tree | 16e8844da058247f8991fa45370796bf0ee01313 | |
parent | 1eb997a84669f158de9dd16a9e54d279cec22293 (diff) | |
download | haskell-67a86b4d4d21954bae7aaddec7617228025a8270.tar.gz |
Add MonadZip and MonadFix instances for Complex
These instances are taken from
https://hackage.haskell.org/package/linear-1.21/docs/Linear-Instances.html
They are the unique possible, so let they be in `base`.
-rw-r--r-- | libraries/base/Data/Complex.hs | 10 | ||||
-rw-r--r-- | libraries/base/changelog.md | 2 |
2 files changed, 12 insertions, 0 deletions
diff --git a/libraries/base/Data/Complex.hs b/libraries/base/Data/Complex.hs index a544a5bf6c..b32844057d 100644 --- a/libraries/base/Data/Complex.hs +++ b/libraries/base/Data/Complex.hs @@ -42,6 +42,8 @@ import GHC.Float (Floating(..)) import Data.Data (Data) import Foreign (Storable, castPtr, peek, poke, pokeElemOff, peekElemOff, sizeOf, alignment) +import Control.Monad.Fix (MonadFix(..)) +import Control.Monad.Zip (MonadZip(..)) infix 6 :+ @@ -251,6 +253,14 @@ instance Applicative Complex where instance Monad Complex where a :+ b >>= f = realPart (f a) :+ imagPart (f b) +-- | @since 4.15.0.0 +instance MonadZip Complex where + mzipWith = liftA2 + +-- | @since 4.15.0.0 +instance MonadFix Complex where + mfix f = (let a :+ _ = f a in a) :+ (let _ :+ a = f a in a) + -- ----------------------------------------------------------------------------- -- Rules on Complex diff --git a/libraries/base/changelog.md b/libraries/base/changelog.md index f612d29128..a0c3234137 100644 --- a/libraries/base/changelog.md +++ b/libraries/base/changelog.md @@ -25,6 +25,8 @@ * An issue with list fusion and `elem` was fixed. `elem` applied to known small lists will now compile to a simple case statement more often. + + * Add `MonadFix` and `MonadZip` instances for `Complex` ## 4.14.0.0 *TBA* * Bundled with GHC 8.10.1 |