[Haskell-cafe] Type Directed Name Resolution

Sebastian Fischer fischer at nii.ac.jp
Wed Nov 10 22:02:52 EST 2010


On Nov 10, 2010, at 11:57 PM, Neil Brown wrote:

> I wonder if special syntax is actually needed for this.  How much of  
> the language would be broken by adopting the general rule: "If the  
> only definitions of f are at the top-level or imported, find the  
> type of 'a' and the type of all the in-scope 'f' s.  If there is  
> exactly one match then use it, otherwise it's an error."?

Interesting idea. It is only after your question that I see TDNR as ad- 
hoc overloading and not only as simpler record notation (although it's  
obvious in retrospect). Such a change without new syntax seems quite  
radical, maybe too radical for a strongly typed language.

On Nov 11, 2010, at 3:05 AM, Albert Y. C. Lai wrote:

> Typed-directed name resolution brings Haskell closer to a write-only  
> language; that is, an ambiguous phrase made total sense to the  
> author when the author wrote it, but an independent reader will need  
> extraordinary effort to disambiguate.

In this regard it would be closer to natural language where it is the  
responsibility of writers to express themselves clearly. Who writes  
something that requires extraordinary effort to disambiguate is an  
incompetent writer (or a poet, like the author of the buffalo  
sentence). Why blame languages instead of writers?

On Nov 11, 2010, at 7:01 AM, Ryan Ingram wrote:

> regular ad-hoc overloading does not make a ton of
> sense in Haskell; function types are complicated enough that too much
> ambiguity is introduced and inference becomes very difficult.  But I
> see a lot of value in locally saying 'this particular invocation
> should be ad-hoc overloaded' for common functions like 'length',
> 'map', 'lookup', etc.

So the current proposal looks like a sensible compromise.

Sebastian


More information about the Haskell-Cafe mailing list