summaryrefslogtreecommitdiff
path: root/testsuite/tests/indexed-types/should_compile/T7837.hs
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2013-04-16 09:54:40 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2013-04-16 09:54:40 +0100
commit665bf5800590a9581fb441ee026ae81d32368398 (patch)
treef24831bd2ee5b483eb91e8bfa46a9f663fc9a625 /testsuite/tests/indexed-types/should_compile/T7837.hs
parent0e489e5759277389fda3cb985b9a934d962b94eb (diff)
downloadhaskell-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.hs24
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)