[cvs-nhc98] Obtain also type signature for worker from type signature

Olaf Chitil olaf@sparud.net
Thu, 13 Feb 2003 18:05:54 +0100 (CET)


olaf: Thu Feb 13 18:05:53 CET 2003

Update of /usr/src/master/nhc/src/hat/lib
In directory hinken:/tmp/cvs-serv5827/src/hat/lib

Modified Files:
	Makefile 
Log Message:
Obtain also type signature for worker from type signature for a function.

Type signatures for workers are needed after introduction of the
known-arity optimisation. The known-arity optimisation requires that
workers of functions with known arity are defined on the same level as
their wrapper, not local to them. If the original function was
recursive, the worker will be recursive instead of calling the wrapper
(as without known-arity opt.). Hence if the original definition had a
type signature, then the worker needs a type signature as well (the
wrapper gets one anyway), because otherwise its inferred type might
not be general enough (polymorphic recursion) or too general (type
class ambiguities, problems with existential types).

Transformation of the original type signature into the worker type
signature is not uniform: function types are handled specially. So if
the type includes a type synonym it may not be possible to use the
transformed type synonym, but the original one has to be expanded and
transformed in this non-uniform way. However, in general a type
synonym cannot be expanded, because the rhs might not be in scope at
the synonym use site. Hence a type synonym is split into an outer part
consisting of function types,type applications and type variables,
which can and may need to be expanded, and several inner type parts,
for which new helper type synonyms are defined. These are always ex-
and imported with the type synonym itself.

A lot of effort, but it does work in the end.