21 Dec
2000
21 Dec
'00
12:11 p.m.
Simon Peyton-Jones wrote:
I think you can simplify the example. Given
class HasFoo a b | a -> b where foo :: a -> b
instance HasFoo Int Bool where ...
Is this legal?
f :: HasFoo Int b => Int -> b f x = foo x
You might think so, since HasFoo Int b => Int -> b is a substitution instance of HasFoo a b => a -> b
but if we infer the type (HasFoo Int b => Int -> b) for f's RHS, we can then "improve" it using the instance decl to (HasFoo Int Bool => Int -> Bool), and now the signature isn't a substitution insance of the type of the RHS.
I definitely want it to be legal. I have examples where this is immensly useful. -- -- Lennart