From fed13cf4654156ae813a51750b514f2e6321e94a Mon Sep 17 00:00:00 2001 From: sof Date: Thu, 9 Jul 1998 08:01:14 +0000 Subject: [PATCH] [project @ 1998-07-09 08:01:13 by sof] Check if one method dict bug in 3.02 has been squashed --- ghc/tests/typecheck/should_run/tcrun003.hs | 26 ++++++++++++++++++++++++ ghc/tests/typecheck/should_run/tcrun003.stdout | 1 + 2 files changed, 27 insertions(+) create mode 100644 ghc/tests/typecheck/should_run/tcrun003.hs create mode 100644 ghc/tests/typecheck/should_run/tcrun003.stdout diff --git a/ghc/tests/typecheck/should_run/tcrun003.hs b/ghc/tests/typecheck/should_run/tcrun003.hs new file mode 100644 index 0000000..86eb318 --- /dev/null +++ b/ghc/tests/typecheck/should_run/tcrun003.hs @@ -0,0 +1,26 @@ +--!!! One method class from Sergey Mechveliani +-- showed up problematic newtype dict rep. +module Main where +import Ratio + +class MBConvertible a b where cm :: a -> b -> Maybe b + +c :: MBConvertible a b => a -> b -> b +c a b = case cm a b + of + Just b' -> b' + _ -> error "c a b failed" + + +instance MBConvertible Int Int where cm a _ = Just a + +instance (MBConvertible a b,Integral b) => MBConvertible a (Ratio b) + where + cm a f = case cm a (numerator f) of Just a' -> Just (a'%1) + _ -> Nothing + +main = let f = 1%1 :: Ratio Int + n2 = 2::Int + g = (c n2 f) + f + in + putStr (shows g "\n") diff --git a/ghc/tests/typecheck/should_run/tcrun003.stdout b/ghc/tests/typecheck/should_run/tcrun003.stdout new file mode 100644 index 0000000..14896f2 --- /dev/null +++ b/ghc/tests/typecheck/should_run/tcrun003.stdout @@ -0,0 +1 @@ +3 % 1 -- 1.7.10.4