Covariance and Controvariance: a fresh look at an old issue (a primer in advanced type systems for learning functional programmers)

09/05/2018
by   Giuseppe Castagna, et al.
0

Twenty years ago, in an article titled "Covariance and contravariance: conflict without a cause", I argued that covariant and contravariant specialization of method parameters in object-oriented programming had different purposes and deduced that, not only they could, but actually they should both coexist in the same language. In this work I reexamine the result of that article in the light of recent advances in (sub-)typing theory and programming languages, taking a fresh look at this old issue. Actually, the revamping of this problem is just an excuse for writing an essay that aims at explaining sophisticated type-theoretic concepts, in simple terms and by examples, to undergraduate computer science students and/or willing functional programmers. Finally, I took advantage of this opportunity to describe some undocumented advanced techniques of type-systems implementation that are known only to few insiders that dug in the code of some compilers: therefore, even expert language designers and implementers may find this work worth of reading.

READ FULL TEXT

page 1

page 2

page 3

page 4

02/26/2019

Induction, Coinduction, and Fixed Points in PL Type Theory

Recently we presented a concise survey of the formulation of the inducti...
12/25/2018

Induction, Coinduction, and Fixed Points: A Concise Survey

In this survey paper (which hitherto is an ongoing work-in-progress) we ...
12/25/2018

Induction, Coinduction, and Fixed Points: A Concise Comparative Survey (and Tutorial)

In this survey paper (which hitherto is an ongoing work-in-progress) we ...
07/26/2022

Design of Classes I

The use of functional programming languages in the first programming cou...
04/01/2021

Immutability and Design Patterns in Ruby

Functional Programming has seen a resurgence in interest in the last few...
06/22/2022

Functional or imperative? On pleasant semantics for differentiable programming languages

In machine learning (ML), researchers and engineers seem to be at odds. ...