[Haskell-cafe] Type vs TypeClass duality

Sebastian Sylvan sebastian.sylvan at gmail.com
Tue Oct 23 18:32:20 EDT 2007

On 23/10/2007, Jules Bean <jules at jellybean.co.uk> wrote:

> I will also repeat the non-justified assertion that others have made,
> and that I've made myself in the other thread, that you don't need
> existentials as often in haskell as you do in OO languages, and they
> certainly don't always need to be type-class quantified ones.

I also find this, but I worry that it's the old blub paradox again.
Haskell makes it a tiny bit clumsy to do value-based dispatch, so you
tend to solve problems in ways which doesn't require it. I'm not
saying that's the case, but I just can't say that the reason I find
myself not using existentials is because I don't need them (whereas
they're immensely useful in other languages).

I think I've suggested this before, but some sort of syntactical gizmo
for expressing "the data type which wraps values in class C, and is
also instantiated in C itself" and just automatically construct the
apropriate existential whenever someone uses it, might be worthwhile.
Perhaps something like enclosing the class name in angle brackets or
something. There needs to be an equivalent way of wrapping the value
itself (constructing the wrapper data type), of course (angle brackets
again for consistency?). Or automatic type conversion could work,
though that seems a bit "un-Haskell" to me.

Sebastian Sylvan
UIN: 44640862

More information about the Haskell-Cafe mailing list