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:
“The Oriental philosophy approaches easily loftier themes than the modern aspires to; and no wonder if it sometimes prattle about them. It only assigns their due rank respectively to Action and Contemplation, or rather does full justice to the latter. Western philosophers have not conceived of the significance of Contemplation in their sense.”
—Henry David Thoreau (18171862)