[Haskell-cafe] Re: Overloading functions based on arguments?

Daniel Fischer daniel.is.fischer at web.de
Fri Feb 13 14:06:10 EST 2009


Am Freitag, 13. Februar 2009 19:49 schrieb Jonathan Cast:
> On Fri, 2009-02-13 at 11:45 -0700, John A. De Goes wrote:
> > On Feb 13, 2009, at 11:32 AM, Jonathan Cast wrote:
> > > I believe the last time it was brought up, the proposal was that type
> > > inference should fail on certain typeable terms.  That doesn't count.
> >
> > I'm referring to a rather conservative proposal wherein if there is
> > one and exactly one definition that allows an expression to type, then
> > name overloading in the same scope is permitted.
> >
> > Aside from exponential performance in pathological (but unlikely)
> > cases, what issue do you have with such a proposal?
>
> It breaks type inference.  I explained this at the time.  I can explain
> it again:
>
>   import Data.List
>   import Data.Set
>   import Data.Map
>
>   warmFuzzyThingFirstOperation = map

To do justice to the above proposal, in that situation more than one choice 
would typecheck (were the other imports absent or qualified), so that should 
also be rejected according to it. I believe what is desired is to be able to 
write

thingummybob :: Ord a => [a] -> (Int,Set a)
thingummybob xs = let st = fromList xs in (size st, st)

with several 'fromLists's in scope. I think it wouldn't be worth the hassle to 
implement that, but otherwise I agree it'd not (necessarily) be a bad thing.

>
> This gives an error currently.  Quite properly.  But if *any* use of
> `map' type-checks, with those imports, why on earth should this one
> fail?  You don't want to remove a wart from the language, you want to
> introduce one!
>
> jcc
>

Cheers,
Daniel



More information about the Haskell-Cafe mailing list