[Haskell-cafe] language proposal: ad-hoc overloading

Andrew Coppin andrewcoppin at btinternet.com
Sun Aug 31 16:37:25 EDT 2008


Ryan Ingram wrote:
> 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.
>
> Pros: shorter code, less busywork to please the compiler
> Cons: potentially exponential compile time?
>
> Any thoughts?
>   

Now try importing something like Data.Map where almost every single 
function name clashes with the Prelude. If I write

  foo x = map (bar x)

then unless there are some explicit type signatures somewhere, the poor 
compiler has no way of knowing whether this function is mapping over a 
list or a Map.

(Arguably you might wish to write a function that does both. This 
quickly boils down to an argument along the lines of "Haskell doesn't 
support container neutrality very well", which as I understand it is 
already a known problem.)



More information about the Haskell-Cafe mailing list