Skip to content
Snippets Groups Projects
Commit fed13cf4 authored by sof's avatar sof
Browse files

[project @ 1998-07-09 08:01:13 by sof]

Check if one method dict bug in 3.02 has been squashed
parent 2c0b0f40
No related merge requests found
--!!! 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")
3 % 1
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment