From d112b15d6a086360276d8a5a59bc1dfa15a3f9b8 Mon Sep 17 00:00:00 2001 From: simonpj Date: Tue, 28 Nov 2000 11:38:35 +0000 Subject: [PATCH] [project @ 2000-11-28 11:38:35 by simonpj] Trim example --- ghc/tests/typecheck/should_compile/tc110.hs | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/ghc/tests/typecheck/should_compile/tc110.hs b/ghc/tests/typecheck/should_compile/tc110.hs index 9f9fa24..1422d89 100644 --- a/ghc/tests/typecheck/should_compile/tc110.hs +++ b/ghc/tests/typecheck/should_compile/tc110.hs @@ -8,28 +8,15 @@ module ShouldCompile where -- Reported by Thomas Hallgren Nov 00 -foo = dup 1 >>= print +primDup :: Int -> IO Int +primDup = undefined -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) +dup () = call primDup -class Call c h | c -> h where call :: c -> h -- (1) problematic ---class Call c h where call :: c -> h -- (2) ok +class Call c h | c -> h where + call :: c -> h -class Result c h | c -> h where fromC :: c -> IO h +instance Call c h => Call (Int->c) (Int->h) where + call f = call . f -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. --} -- 1.7.10.4