[Haskell] PROPOSAL: class aliases

Andres Loeh loeh at iai.uni-bonn.de
Thu Oct 13 06:46:21 EDT 2005

> One thought: how will class aliases interact with type inference?
> e.g. if a declaration contains only a call to 'foo', should we infer
> the constraint Foo a, or FooBar a?  Can there ever be a situation where
> choosing the more specific dictionary could leave us without a 'bar'
> method at some later point in the computation?  (cf. up-casting and
> down-casting in OO languages).
> If I declare a function
>     baz :: Bar a => ...
> and then pass it a value which actually has a FooBar dictionary rather
> than just a Bar, will the implementation be able to find the right
> offset in the dictionary for the 'bar' method?  How?  (I know jhc
> eliminates dictionaries at compile-time, but other implementations
> do not.)

The way I understand the proposal, there are no FooBar dictionaries
ever. John said that this can be translated by a source-to-source
translation, so internally, a FooBar dictionary *is* a Foo and a
Bar dictionary.

How much static checking can be done before desugaring the code? Will
it be possible to give sensible error messages, or will those mention
the "internal" classes that the alias is supposed to hide?


More information about the Haskell mailing list