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

Krzysztof Skrzętnicki gtener at gmail.com
Fri Feb 13 20:31:04 EST 2009


On Fri, Feb 13, 2009 at 22:37, John A. De Goes <john at n-brain.net> wrote:
> On Feb 13, 2009, at 2:11 PM, Jonathan Cast wrote:
>>
>> The compiler should fail when you tell it two mutually contradictory
>> things, and only when you tell it two mutually contradictory things.
>
> By definition, it's not a contradiction when the symbol is unambiguously
> typeable. Do you think math textbooks are filled with contradictions when
> they give '+' a different meaning for vectors than matrices or real
> numbers???

I can easily imagine a book which uses some operator in ambiguous way
yet relies on readers' intelligence in solving that issue. It is OK to
do that as
long as it is easy. However: it can get arbitrarily worse. I would
consider any book which is hard
to read because of that badly written. Things are quite similar with the code.

> Type is implicitly or explicitly a part of the definition of every function.
> It's not the name that need be unique, but the name over a given domain.
> When two functions have different domains, the same name can be
> unambiguously used to describe both of them.

I think the whole point is not about what is and what isn't possible
to implement.
For example GHC often can do just fine with undecidable instances
despite the problems they may cause.
Programming language should be easy to reason about for both computers
and humans. Compiler should therefore disallow programming style that is
inaccessible for potential readers. Want to overload something? Well,
use typeclasses to
be explicit about it.

All best

Christopher Skrzętnicki


More information about the Haskell-Cafe mailing list