Commit 67a86b4d authored by Oleg Grenrus's avatar Oleg Grenrus Committed by Marge Bot

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`.
parent 1eb997a8
......@@ -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
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment