Type class

In computer science, a type class is a type system construct that supports ad hoc polymorphism. This is achieved by adding constraints to type variables in parametrically polymorphic types. Such a constraint typically involves a type class T and a type variable a, and means that a can only be instantiated to a type whose members support the overloaded operations associated with T.

Type classes were first implemented in the Haskell programming language after first being proposed by Philip Wadler and Stephen Blott as an extension to "eqtypes" in Standard ML,[1][2] and were originally conceived as a way of implementing overloaded arithmetic and equality operators in a principled fashion.[3][2] In contrast with the "eqtypes" of Standard ML, overloading the equality operator through the use of type classes in Haskell does not require extensive modification of the compiler frontend or the underlying type system.[4]

  1. ^ Morris, John G. (2013). Type Classes and Instance Chains: A Relational Approach (PDF) (PhD). Department of Computer Science, Portland State University. doi:10.15760/etd.1010.
  2. ^ a b Wadler, P.; Blott, S. (1989). "How to make ad-hoc polymorphism less ad hoc". Proceedings of the 16th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL '89). Association for Computing Machinery. pp. 60–76. doi:10.1145/75277.75283. ISBN 0897912942. S2CID 15327197.
  3. ^ Kaes, Stefan (March 1988). "Parametric overloading in polymorphic programming languages". Proc. 2nd European Symposium on Programming Languages. doi:10.1007/3-540-19027-9_9.
  4. ^ Appel, A.W.; MacQueen, D.B. (1991). "Standard ML of New Jersey". In Maluszyński, J.; Wirsing, M. (eds.). Programming Language Implementation and Logic Programming. PLILP 1991. Lecture Notes in Computer Science. Vol. 528. Springer. pp. 1–13. CiteSeerX 10.1.1.55.9444. doi:10.1007/3-540-54444-5_83. ISBN 3-540-54444-5.

© MMXXIII Rich X Search. We shall prevail. All rights reserved. Rich X Search