whole-dekker-thesis.pdf (5.11 MB)
Subtype inference in functional languages
thesisposted on 2023-05-27, 07:31 authored by Dekker, AH
This thesis describes techniques for efficiently performing polymorphic type inference for functional programming languages in the presence of subtype relationships. We permit subtype relationships which are based on implicit coercion functions between primitive types or type constructors, such as between integers and reals or between lists of arbitrary type and sets of the same type. Coercions between different kinds of functions are also pennitted. In particular, finite database functions can be coerced to general functions. This makes functional languages useful as database query and update languages. In the first chapter we describe basic notation, and define a subtype ordering to be a partial order on type variables and type constructors, satisfying certain conditions which ensure that the inequalities in a subtype ordering always have a solution. We define a number of operations for manipulating subtype orderings, which exploit the representation of subtype orderings as transitively reduced directed acyclic graphs. Generic operations such as addition are given a type scheme containing a subtype ordering which constrains the bound variables. Colouring of type variables imposes a further constraint, which allows a type scheme to be given to the equality function. The second chapter defines a simple functional language and gives inference rules which type-annotate expressions. A number of additional rules are derived, including a rule for applying a substitution to a typing assertion. We provide a rewrite rule semantics for typed expressions, and show that this preserves typing information and is Church-Rosser. Since coercions produce a unique result and commute with primitive operations, including equality, we conjecture that type-annotating an expression is semantically unambiguous. In the third chapter we give a sound and complete, but naive, type inference algorithm which is inefficient, since intermediate subtype orderings rapidly become large. Standardisations and simplifications, which reduce the size of subtype orderings without loss of generality, lead to a more efficient type inference algorithm, which is quartic-time for expressions, but which we expect to be linear for typical user programs. The fourth chapter applies this work to database query and update, using the Functional Data Model. A case study involving a hospital database shows the utility of subtype inference.
Rights statementCopyright the Author-The University is continuing to endeavour to trace the copyright owner(s) and in the meantime this item has been reproduced here in good faith. We would be pleased to hear from the copyright owner(s)