[Haskell-cafe] Overloading

Peter Caspers pcaspers1973 at gmail.com
Sun Mar 10 08:47:35 CET 2013


Thank you all for your answers, this helps a lot. To clarify my last 
point ...

>> Also again, taking this way I can not provide several constructors taking inputs of different types, can I ?
> Sorry, didn't get what you mean here.

In C++ it is perfectly normal to have overloaded functions like

f : Int -> Int -> Int
f : Int -> Char -> Int

in coexistence, because the compiler can infer (at compile time) what 
function to call by looking at the arguments types.

In Haskell I think this is not possible simply due to the flexibility 
given by partial function application, i.e.

f 5

would not be well defined any more, it could be Int -> Int or Char -> Int.

Thanks again and kind regards
Peter









More information about the Haskell-Cafe mailing list