[Haskell-cafe] Re: Overloading functions based on arguments?
Daniel Kraft
d at domob.eu
Fri Feb 13 05:40:43 EST 2009
Colin Adams wrote:
> If you have two functions that do two different things, then they
> certainly OUGHT to have different names.
Well, they do "the same thing" but for different arguments; it's like this:
Table is a table of name-value pairs I want to substitute in a tree-like
structure using:
substitute :: Table -> Tree -> Tree
For substituting a single name-value pair I want to define this utitlity
routine so I don't have to construct a Table all the time in the user code:
substitute :: String -> Value -> Tree -> Tree
In the case I believe it would certainly be good to be able to name both
functions the same, but I fear I can not do so? There are languages
where this is explicitelly allowed (e.g. C++ or Java), so I don't think
it is such an unuseful or evil thing.
Daniel
More information about the Haskell-Cafe
mailing list