Faculty of Information Technology Programming Languages and Systems
Skip to Content
QUT Home FIT Home PLAS Home Projects People Wiki Contacts
 
     

A type inferencer with support for generics

   

Mini Component Pascal was completed as the major work product of an honours project by Brian Blackwell. The immediate predecessor of this project was another honours project by Simeon Cran. As part of his honours thesis, Cran ported a type inferencer by Luca Cardelli for a small functional language that supports ML-style polymorphism. This type inferencer formed the basis of the Mini Component Pascal compiler implementations. An online version of this type inferencer is available.

From Cran's honours thesis:

This part of the project was based around a paper by Luca Cardelli that is designed to illustrate the Hindley-Milner type inferencing algorithm. The paper discusses the algorithm in detail, and includes a partial implementation written in Modula-2. Cardelli has omitted modules from the code that are required to actually test and observe the implementation: most significantly, there is no scanner, parser, driver, or error handler. It was decided to port the Cardelli code to Component Pascal, and to create the missing modules so that a type inferencing program could be built and observed [...]

Cardelli presentation of the algorithm uses a typed version of the Lambda calculus, noting its similarity to a simplified version of Milner’s language ML. The type inferencing program [...] parses and types programs of this simple language, and further examples are based on it.

The concrete syntax of the language supported by the type inferencer is as follows:

Exp ::=
    Ide |
    "if" Exp "then" Exp "else" Exp |
    "fun" "(" Ide ")" Exp |
    Exp "(" Exp ")" |
    "let" Decl "in" Exp |
    "(" Exp ")"
Decl ::=
    Ide "=" Exp |
    Decl "then" Decl |
    "rec" Decl |
    "(" Decl ")"
    

The type inferencer comes with a number of functions pre-loaded into the environment:

OperatorType
true, falsebool
0int
succ, predint -> int
timesint -> (int -> int)
plusint -> (int -> int)
minusint -> (int -> int)
eqint -> (int -> bool)
zeroint -> bool
pairA -> (B -> (A x B))
fst(A x B) -> A
snd(A x B) -> B
nil[A]
cons(A x ( [A])-> ( [A])
hd[A] -> A
tl[A] -> A [A]
null[A] -> bool
inlA -> (A + B)
inrB -> (A + B)
outl(A + B) -> A
outr(A + B) -> B
isl(A + B) -> bool
isr(A + B) -> bool

PLAS
Projects
  ActiveSheets
  Bioinformatics
  ConcernMaps
  ELP
  ELP.NET
  G2 Cluster Computing
  Generics
    Mini Component Pascal
      Background
      FMCP
      IMCP
      IMCPI
      IMCPG
      Cardelli type inferencer
      Online compilers
  Gardens Point Component Pascal
  Gardens Point Flow
  Gardens Point Modula
  Gardens Point Service Language
  Language Processing Tools
  Mentok
  Metaphor
  Mobilizer
  RikWik
  Ruby.NET
People
Wiki
Contacts