Hacker News new | ask | show | jobs
by dmooney1 5288 days ago
I agree - type overloading says templates to me rather than inheritance. C++'s tuple class lets you do some of the cool listy type things you can do in Haskell. Using typedef tuple<double, double> FloatPoint and taking it from there seems a lot more like the Haskell example and would be less code - one line each for the typedefs and a one-line function to implement <<. (Not taking anything away from Haskell, which I'm completely in love with.)
1 comments

The typedef tuple strategy doesn't let you distinguish between types except by the types and ordering of their fields. If you later have a constructor for another ADT (or even the same one) which also takes two Float arguments, you end up with multiple typedefs for tuple<double, double>.