Skip to content

Lazy skolemisation for @a-binders (#17594)

Andrei Borzenkov requested to merge wip/sand-witch/lazy-skol into master

This is the draft of lazy skolemisation approach that we discussed here #17594 (comment 522656)

This patch is a preparation for @a-binders implementation. We have to accept SigmaType in matchExpectedFunTys function to implement them. To achieve that, I made skolemization more lazy. This leads to

  • Added new flag SkolemizeTypeScoped = DoSkolemiseScoped | DontSkolemiseScoped
  • Changing tcPolyCheck function. Now it doesn't skolemize the type from signature and passes DoSkolemiseScoped inside tc_match_fun.
  • tc_match_fun function now (only if DoSkolemiseScoped is passed to it) reconstructs skolemised type from rhs_type and exp_pat_tys to pass this type into tcExtendBinderStack
  • match_expected_fun_tys now accepts flag SkolemizeTypeScoped and calls tcSkolemiseScoped on the argument if DoSkolemiseScoped is passed
  • Changing tcExprSig function, so now it only skolemises signature if there is ScopedTypeVariables extension enabled.
  • Changing tcPolyExpr function. Now it goes deeper into type if type actually is
    1. HsPar
    2. HsLam In all other cases tcPolyExpr immediately skolemises a type as it was previously.

These changes would allow lambdas to accept invisible type arguments in the most interesting contexts.

cc @rae @simonpj

Edited by Andrei Borzenkov

Merge request reports