
26 Jul
2010
26 Jul
'10
1:30 p.m.
On Sun, Jul 25, 2010 at 1:53 PM, Alexey Karakulov
Suppose I have one piece of code like this:
class Result r e | r -> e where failure :: e -> r a success :: a -> r a
Maybe instance is discarding failure information:
instance Result Maybe e where failure _ = Nothing success x = Just x
I would argue that this shouldn't successfully compile. Your class declaration claims that given r, you can uniquely determine e. But you've effectively defined instance Result Maybe () instance Result Maybe Int ... many more instances ... which means that isn't the case. I wonder if there is a potential type safety failure in the compiler with instances of this form? -- ryan