Skip to content

Add support for higher-rank polymorphism

Jan-Hendrik Matthes requested to merge higher-rank-polymorphism into master

This merge request adds support for higher-rank polymorphism to the frontend.

The extension of the existing type system is based on the paper Practical type inference for arbitrary-rank types also implemented by Haskell. The new type system is still predicative. An instantiation of type variables with higher-rank types is not allowed. But Curry programmers use the ($)-operator so much, to avoid writing parentheses, that the extended type inference has an ad-hoc special case for x $ y (just like Haskell) that allows it to do type inference for x $ y, even when impredicative polymorphism is needed.

Depends on curry-base!9 (merged)

Work that needs to be done:

  • Convert forall types to AbstractCurry
  • Add RankNTypes to the known language extensions of the frontend
  • Convert the TypeScheme data type into a forall type
  • Allow type constraints nested within type expressions
  • Implement the new typing rules
  • Adapt the checks and transformations
  • Detect impredicative polymorphism
  • Correct typing of higher-rank functions with predicates
  • Add tests for RankNTypes to the test suite

Bugs that need to be fixed:

Edited by Jan-Hendrik Matthes

Merge request reports

Loading