Other Approaches To Operator Overloading
In Standard ML, the mechanism of "equality types" corresponds roughly to Haskell's built-in type class Eq
, but all equality operators are derived automatically by the compiler. The programmer's control of the process is limited to designating which type components in a structure are equality types and which type variables in a polymorphic type range over equality types.
SML's and OCaml's modules and functors can play a role similar to that of Haskell's type classes, the principal difference being the role of type inference, which makes type classes suitable for ad hoc polymorphism. The object oriented subset of OCaml is yet another different approach which is somewhat comparable to the one of type classes.
Read more about this topic: Type Class
Famous quotes containing the word approaches:
“These were not men, they were battlefields. And over them, like the sky, arched their sense of harmony, their sense of beauty and rest against which their misery and their struggles were an offence, to which their misery and their struggles were the only approaches they could make, of which their misery and their struggles were an integral part.”
—Rebecca West (18921983)