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

Philippa Cowderoy flippa at flippac.org
Sun Aug 31 20:41:16 EDT 2008


Oops, forgot to send to list.

On Mon, 2008-09-01 at 01:27 +0100, Philippa Cowderoy wrote:
> On Mon, 2008-09-01 at 01:11 +0100, David House wrote:
> > 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:
> > 
> > import Data.Map
> > foo = map
> > 
> > What is the type of `foo'?
> 
> If I've understood the proposal, that wouldn't check unless foo was used
> in a way (within the module) that makes it clear which of Prelude.map or
> Data.Map.map to use and uses it consistently. So if that's the entire
> module, it wouldn't check.
> 
> I'm still not keen, but in a sense the idea here is to avoid this
> variety of overloading leaking into the type system itself: it could be
> implemented (extremely naively) as "typecheck with each possible
> permutation for resolving the overloading, use any unique solution or
> fail if there isn't one".

-- 
Philippa Cowderoy <flippa at flippac.org>



More information about the Haskell-Cafe mailing list