Semantics of type classes revisited

  • Authors:
  • Satish R. Thatté

  • Affiliations:
  • Department of Mathematics and Computer Science, Clarkson University, Potsdam, NY

  • Venue:
  • LFP '94 Proceedings of the 1994 ACM conference on LISP and functional programming
  • Year:
  • 1994

Quantified Score

Hi-index 0.00

Visualization

Abstract

We present a new approach to the semantics of languages with ML-like polymorphic types and type classes. The goals of the new approach are simplicity and generality. Our typing rules are a relatively straightforward extension of the rules for translating core-ML to core-XML. The new features are an encoding of classes as recursive sets of types, and class-membership constraints on types. We show that the soundness of this type of system is independent of the fixedpoint operator used to interpret (recursive) classes, and thus there is no room to engineer a sound notion of well-typing based on other considerations such as decidability. These ideas are applied to investigate the appropriateness of Haskell-style type inference which uses backward chaining for inference of instance relationships. Haskell's algorithm turns out to imply a least fixed point semantics for classes. We show that the Haskell approach is correct and complete for the special case of convergent classes. Although this includes all classes definable in Haskell, most proper extensions of Haskell allow classes that are not convergent, which helps explain the negative results for decidability of type inference for many extensions.