[Haskell-cafe] Correction: subclasses and classes with same type in instance
Daniel Fischer
daniel.is.fischer at googlemail.com
Sun Oct 16 22:31:43 CEST 2011
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.
More information about the Haskell-Cafe
mailing list