Commit 665bf580 authored by Simon Peyton Jones's avatar Simon Peyton Jones

Test Trac #7837

parent 0e489e57
{-# LANGUAGE TypeFamilies, FlexibleContexts #-}
module T7837 where
type family Scalar a
class Fractional (Scalar a) => Norm a where
norm :: a -> Scalar a
type instance Scalar Double = Double
instance Norm Double where norm = abs
normalize :: (Norm a, a ~ Scalar a) => a -> a
normalize x = x / norm x
{-# NOINLINE normalize #-}
normalize_Double :: Double -> Double
normalize_Double = signum
{-# NOINLINE normalize_Double #-}
-- This rule should fire in 'foo'
{-# RULES "normalize/Double" normalize = normalize_Double #-}
foo :: Double
foo = normalize (4 :: Double)
Rule fired: Class op abs
Rule fired: Class op signum
Rule fired: normalize/Double
......@@ -209,4 +209,5 @@ test('T7489', normal, compile, [''])
test('T7585', normal, compile, [''])
test('T7282', normal, compile, [''])
test('T7804', normal, compile, [''])
test('T7837', normal, compile, ['-O -ddump-rule-firings'])
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