
16 Oct
2011
16 Oct
'11
4:31 p.m.
On Sunday 16 October 2011, 21:50:13, Patrick Browne wrote:
In the current example does the following totally or partially ignore the type class system. boo :: Shed -> Integer boo h = addressB h + addressH h
It doesn't ignore the type class system at all. It's a monomorphic function using methods from the classes Building and House, so it just has to verify that Shed is an instance of both classes. Without the superclass constraint on House, it's two unrelated lookups, with the superclass constraint, the compiler can choose to lookup both separately, or it could first determine that due to the superclass constraint, it needs only look up the House instance.