diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2013-04-16 09:54:40 +0100 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2013-04-16 09:54:40 +0100 |
commit | 665bf5800590a9581fb441ee026ae81d32368398 (patch) | |
tree | f24831bd2ee5b483eb91e8bfa46a9f663fc9a625 /testsuite/tests/indexed-types/should_compile/T7837.hs | |
parent | 0e489e5759277389fda3cb985b9a934d962b94eb (diff) | |
download | haskell-665bf5800590a9581fb441ee026ae81d32368398.tar.gz |
Test Trac #7837
Diffstat (limited to 'testsuite/tests/indexed-types/should_compile/T7837.hs')
-rw-r--r-- | testsuite/tests/indexed-types/should_compile/T7837.hs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/testsuite/tests/indexed-types/should_compile/T7837.hs b/testsuite/tests/indexed-types/should_compile/T7837.hs new file mode 100644 index 0000000000..45235f8065 --- /dev/null +++ b/testsuite/tests/indexed-types/should_compile/T7837.hs @@ -0,0 +1,24 @@ +{-# 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) |