[cvs-nhc98] patch applied (hat): Obtain also type signature for worker from type signature for a function.

Malcolm Wallace Malcolm.Wallace at cs.york.ac.uk
Tue Oct 10 07:23:53 EDT 2006


Thu Feb 13 09:05:55 PST 2003  olaf
  * 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.

    M ./src/hatlib/Makefile -4 +4
    M ./src/hattrans/AuxFile.hs -5 +31
    M ./src/hattrans/AuxLabelAST.hs -3 +4
    M ./src/hattrans/AuxTypes.hs +4
    M ./src/hattrans/TraceId.hs -2 +11
    M ./src/hattrans/TraceTrans.hs -28 +117


More information about the Cvs-nhc98 mailing list