summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsimonpj <unknown>2000-11-28 08:25:57 +0000
committersimonpj <unknown>2000-11-28 08:25:57 +0000
commit91aba4d8b2eb919dec85a5025602e03ac2704112 (patch)
tree7c8bb49f1ba5edade9e39d66bda936ce4d3a73e1
parentf9fb93ae6521b48810c41cdfc671f5b797b9c5c0 (diff)
downloadhaskell-91aba4d8b2eb919dec85a5025602e03ac2704112.tar.gz
[project @ 2000-11-28 08:25:57 by simonpj]
Add second functional dependency test
-rw-r--r--ghc/tests/typecheck/should_compile/tc110.hs35
-rw-r--r--ghc/tests/typecheck/should_compile/tc110.stderr0
2 files changed, 35 insertions, 0 deletions
diff --git a/ghc/tests/typecheck/should_compile/tc110.hs b/ghc/tests/typecheck/should_compile/tc110.hs
new file mode 100644
index 0000000000..9f9fa244ff
--- /dev/null
+++ b/ghc/tests/typecheck/should_compile/tc110.hs
@@ -0,0 +1,35 @@
+{-# OPTIONS -fglasgow-exts #-}
+
+module ShouldCompile where
+
+-- A stripped down functional-dependency
+-- example that causes GHC 4.08.1 to crash with:
+-- "basicTypes/Var.lhs:194: Non-exhaustive patterns in function readMutTyVar"
+-- Reported by Thomas Hallgren Nov 00
+
+
+foo = dup 1 >>= print
+
+foreign import "dup" primDup :: Int -> IO Int
+--dup :: Int -> IO Int -- not needed with (1), needed with (2)
+dup = call primDup -- ghc crashes here with (1), ok with (2)
+
+class Call c h | c -> h where call :: c -> h -- (1) problematic
+--class Call c h where call :: c -> h -- (2) ok
+
+class Result c h | c -> h where fromC :: c -> IO h
+
+instance Result c h => Call (IO c) (IO h) where call f = fromC =<< f
+instance Call c h => Call (Int->c) (Int->h) where call f = call . f
+
+instance Result Int Int where fromC = return
+
+
+{-
+The example is perhaps too stripped down to illustrate the purpose of these
+classes, but the idea is that the class "Call" should relate suitably declared
+low-level prim_types in foreign imports to sensible, high-level Haskell types,
+allowing high level functions to be obtained by simply applying the method
+"call" to the primitive function, as in the definition of dup above, without
+having to explicitly give also the type of the high level function.
+-}
diff --git a/ghc/tests/typecheck/should_compile/tc110.stderr b/ghc/tests/typecheck/should_compile/tc110.stderr
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/ghc/tests/typecheck/should_compile/tc110.stderr