cs252r : Advanced Functional Programming - Fall 2006

These pages are a record of the in-class discussions for the graduate class "Advanced Functional Programming" given at Harvard University in the Fall of 2006.

November 6, 2006


In system F2 with suitable extensions write a term of type:

 (forall a. a -> a) -> (Int,Bool) 
\f:(forall a . a -> a). (f[Int] 0, f[Bool] True)
\f:(forall a . a -> a). f[Int x Bool] (0,False)

Code your term using the language (Exp:sigma) from the paper.

newtype T = forall a . a -> a
\f:T . (T^{-1} f 0, T^{-1} f True)
\f:(forall a.a->a) . (f 0, f True)

Why is the type inference algorithm in the last section (as opposed to somewhere else in the paper)?

The inference algorithm is not what makes this paper compelling. The non-syntax directed rules are more important for stating properties of the system.

What is the contribution of this paper?

Showing that there is a viable middle ground between inference algorithms that require no annotation, and type checking algorithms that require many annotations. Namely, one can add type annotations only in certain well defined places and still maintain decidability of inference while gaining the expressiveness of F2.

Agree or disagree with the following claim:

According to the numbers that Pierce and Turner summarize at the top of page 253, programming with explicit polymorphism is unworkable.

We agree: every third line is entirely too much annotation.

Please agree among yourselves on the relative degree to which F2 and (Exp:sigma) are unworkable for programmers.

On page 260, Pierce and Turner write:

The difficulties with the greedy algorithm can be traced to the fact that there is no way of giving a robust explanation of its behavior without describing the typing, subtyping, and unification algorithms in complete detail, since the instantiations that they perform are highly sensitive to the precise order in which constraints are encountered during checking.

To what degree does the (Exp:sigma) system suffer from these difficulties?

BibTeX

@InProceedings{Martin-Odersky-and-Konstantin-Laufer1996
  , isbn       = "0-89791-769-3"
  , author     = "Martin Odersky and Konstantin Laufer"
  , year       = 1996
  , publisher  = "ACM Press"
  , title      = "Putting type annotations to work"
  , address    = "New York, NY, USA"
  , location   = "St. Petersburg Beach, Florida, United States"
  , url        = "http://doi.acm.org/10.1145/237721.237729"
  , pages      = "54--67"
  , booktitle  = "Proceedings of the 23rd ACM SIGPLAN-SIGACT symposium on Principles of programming languages"
  }
@InProceedings{Benjamin-C.-Pierce-and-David-N.-Turner1998
  , isbn       = "0-89791-979-3"
  , author     = "Benjamin C. Pierce and David N. Turner"
  , year       = 1998
  , publisher  = "ACM Press"
  , title      = "Local type inference"
  , address    = "New York, NY, USA"
  , location   = "San Diego, California, United States"
  , url        = "http://doi.acm.org/10.1145/268946.268967"
  , pages      = "252--265"
  , booktitle  = "Proceedings of the 25th ACM SIGPLAN-SIGACT symposium on Principles of programming languages"
  }