
25 Sep
2010
25 Sep
'10
3:11 p.m.
On 09/25/10 09:36, Daniel Fischer wrote:
[ratPow :: (Integral b, Integral a) => Ratio b -> a -> Ratio b ratPow ...] ratPow (x:%y) e = reduce2 (x^e) (y^e)
reduce2 = (%) {-# RULES "reduce2/Rational" reduce2 = (:%) :: Integer -> Integer -> Rational #-}
Be careful! To fire that RULE you need to inline or partially specialize ratPow. (re partially specialize, I don't remember if GHC allows specializing to a polymorphic type like Integral a => Rational -> a -> Rational) Anyway this goes rather beyond the proposal. -Isaac