Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Type systems of functional object-oriented languages

I would like to know how exactly modern typed functional object-oriented languages, such as Scala and OCaml, combine parametric polymorphism, subtyping and other their features.

Are they based on System F<:, or something stronger, or weaker?

Is there a well-studied formal type system, like System FC for Haskell, which could serve as a "core" for these languages?

like image 865
Roman Cheplyaka Avatar asked May 24 '13 10:05

Roman Cheplyaka


People also ask

Which is the most widely used OO programming language?

However, C++ is the most successful and widely used general-purpose OO language. The object-oriented programming paradigm came into use as it overcomes certain limitations of other conventional programming paradigms like the structured and unstructured paradigms.

What is Java programming language?

This is a high-level object-oriented programming language that is easy to learn and enables developers to work faster and integrate systems more effectively. It’s a dynamic, interpreted language that emphasizes code readability and supports multiple programming paradigms, including functional, object-oriented, procedural, and imperative.

What is object-oriented programming language?

An object-oriented programming language is a programming language that represents the elements of a problem as objects, which contain data and behavior. Real-world objects are used to model the state and behavior of real-world entities in your application.

What is an object-based language?

• Object-based languages: Languages that support the concept of abstract data types and also other OO concepts like encapsulation, data hiding and operator overloading are known as known as object-.based languages. However, these languages do not support the concept of inheritance and dynamic binding.


1 Answers

OCaml

The "core" of OCaml type theory consists of extensions of System F, but the module system corresponds to a mix of F<: (modules can be coerced into stricter signature by subtyping) and Fω.

In the core language (without considering subtyping at the module level), subtyping is very restricted in OCaml, as subtyping relations cannot be abstracted over (there is no bounded quantification). The language emphasizes polymorphic parametrism instead, and in particular even the "extensible" type it supports use row polymorphism at their core (with a convenience layer of subtyping between closed such types).

For an introduction to type-theoretic presentations of OCaml, see the online book by Didier Remy, Using, Understanding, and Unraveling the OCaml Language (From Practice to Theory and vice versa) . Its further reading chapter will give you more reference, in particular about the treatment of object-orientation.

There has been a lot of work on formalizations of the module system part; arguably, the ML module systems do not naturally fit Fω or F<:ω as a core formalism (for once, type parameters are named in a module system, instead of being passed by position as in lambda-calculi). One of the best explanations of the correspondence is F-ing modules, first published in 2010 by Andreas Rossberg, Claudio Russo and Derek Dreyer.

Jacques Garrigue has also done a lot of work on the more advanced features of the language (that cannot be summarized as "just syntactic sugar over system F"), namely Polymorphic Variants (equi-recursives structural types), labelled arguments, and GADTs). Various descriptions of these aspects can be found on his webpage, including mechanized proofs (in Coq) of polymorphic variants and the relaxed value restriction.

You should also look at the webpage A few papers on Caml, which points to some of the research article around the OCaml language.

Scala

The similar page for Scala is this one. Particularly relevant to your question are:

  • A Core Calculus for Scala Type Checking, by Vincent Cremet, François Garillot, Sergueï Lenglet and Martin Odersky, 2006
  • Generics of a Higher Kind, by Adriaan Moors, Frank Piessens, and Martin Odersky, 2008
like image 50
gasche Avatar answered Oct 22 '22 23:10

gasche