[Haskell-cafe] language proposal: ad-hoc overloading
dmhouse at gmail.com
Sun Aug 31 20:11:29 EDT 2008
2008/8/31 Ryan Ingram <ryani.spam at gmail.com>:
> My proposal is to allow "ad-hoc" overloading of names; if a name is
> ambiguous in a scope, attempt to type-check the expression against
> each name. It is only an error if type-checking against all names
> fails. If type-checking succeeds for more than one then the
> expression is ambiguous and this is also an error.
-1, at least for now.
Haskell already has one method of overloading: type classes. What you
propose is a seemingly innocent extension that I now doubt has
extremely far-reaching consequences into the language. Such a feature
should be properly researched before it is added to the language.
Here's an example of such a concern: you write the following:
foo = map
What is the type of `foo'? I can think of several solutions to this
problem: one that springs to mind is to create something akin to an
"on-the-fly" typeclass "class HasMap h where map :: h" and add
instances for [a] and Ord k => Map k a. But I suspect there are other
options, with differing semantics. What if you further define bar =
map (+1), what happens then? Etc. etc.
The point I'm trying to make is that such a seemingly simple change is
in actual fact not nearly as simple as you might expect. So we should
consider carefully how this changes the language, and whether it's
More information about the Haskell-Cafe