[Haskell-cafe] language proposal: ad-hoc overloading
deduktionstheorem at web.de
Sun Aug 31 17:20:20 EDT 2008
Miguel Mitrofanov wrote:
> Suppose you have different thing all named "insertWith". You've got one
> somewhere in your program; how do YOU know when looking at the code
> after a month or so, which one is this?
We already have that situation when classes are involved. If you replace
specialised functions by abstractions provided classes, for instance
mempty instead of Data.Structure.empty
fmap instead of Data.Structure.map
folds from Data.Foldable instead of a specialised module
There certainly are more examples, but these are the most common.
IMHO this doesn't make code much harder to read. mempty gives us some
empty data structre, fmap applies a function to all its elements and
folds do the same. It doesn't matter if we're talking about lists, sets
or something else.
And it has the huge advantage that you can replace a data structure by
another (Maybe by ,  by Set, ...) simply by changing a type
signature and not the code.
> Certainly, given a smart IDE you
> can ask it; but I think that code should be clear just when you look at
> it, without any action.
I think that - at least in the examples listed above - the code remains
Früher hieß es ja: Ich denke, also bin ich.
Heute weiß man: Es geht auch so.
- Dieter Nuhr
More information about the Haskell-Cafe