[Haskell-cafe] Type Directed Name Resolution

Richard O'Keefe ok at cs.otago.ac.nz
Wed Nov 10 20:29:26 EST 2010

On 10/11/2010, at 11:56 PM, Ozgur Akgun wrote:

> I still don't know whether I like this idea or not, but here is the simplest definition I can think of about what it promises.
> Using TDNR, it will be possible to write the following code:
> data Foo = Foo { name :: String }
> data Bar = Bar { name :: String }
> getName :: Either Foo Bar -> String
> getName (Left  f) = name f
> getName (Right b) = name b
> However, currently you cannot: "Multiple declarations of 'name'"

It's not clear why this is a bad thing.
If the two "name" functions MEAN the same thing (at some level
of abstraction) they can/should belong to the same typeclass,
in which case there is already no problem.

If they don't mean the same thing, then getName has no coherent

Grepping through an old release of the Erlang/OTP system, I
 - approximately six thousand record declarations in
 - roughly one and a half million raw lines,
   or about one million SLOC.
In Erlang, field access is
	<record expression> # <record name> . <field name>
e.g.,	Event#event.trace_ts

It doesn't seem to be a problem.  In fact, for programming in
the large it seems to be regarded more as a feature, just as
always using a module prefix on imported functions is regarded
as "best practice".

So if being explicit is *good* for programming-in-the-large
in Erlang, why is it *bad* for Haskell?

More information about the Haskell-Cafe mailing list