[commit: ghc] master: Add specialization rules for realToFrac on Complex (5800b02)
git at git.haskell.org
git at git.haskell.org
Tue Jan 3 05:52:23 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/5800b02a1910a468485b272a2063377e8b06ee1d/ghc
>---------------------------------------------------------------
commit 5800b02a1910a468485b272a2063377e8b06ee1d
Author: Takano Akio <tak at anoak.io>
Date: Tue Jan 3 00:20:24 2017 -0500
Add specialization rules for realToFrac on Complex
This patch implements RULES that specialize realToFrac at these 2 types:
`(Real a) => a -> Complex Double`
`(Real a) => a -> Complex Float`
Test Plan: ./validate
Reviewers: austin, hvr, bgamari
Reviewed By: bgamari
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2901
GHC Trac Issues: #13040
>---------------------------------------------------------------
5800b02a1910a468485b272a2063377e8b06ee1d
libraries/base/Data/Complex.hs | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/libraries/base/Data/Complex.hs b/libraries/base/Data/Complex.hs
index 17ef805..efdc1c5 100644
--- a/libraries/base/Data/Complex.hs
+++ b/libraries/base/Data/Complex.hs
@@ -235,3 +235,16 @@ instance Applicative Complex where
-- | @since 4.9.0.0
instance Monad Complex where
a :+ b >>= f = realPart (f a) :+ imagPart (f b)
+
+-- -----------------------------------------------------------------------------
+-- Rules on Complex
+
+{-# RULES
+
+"realToFrac/a->Complex Double"
+ realToFrac = \x -> realToFrac x :+ (0 :: Double)
+
+"realToFrac/a->Complex Float"
+ realToFrac = \x -> realToFrac x :+ (0 :: Float)
+
+ #-}
More information about the ghc-commits
mailing list