Skip to content

Visible type application and data constructors

Simon Peyton Jones requested to merge wip/T18481 into master

There are two patches here

One fixes #19768 (closed). There was nothing difficult here, although it touches a lot of files.

The second fixes #18481 (closed) and #19775 (closed), plus refactors HsConLikeOut so that it doesn't pollute Language.Haskell.Syntax.

    Allow visible type application for levity-poly data cons
    
    This patch was driven by #18481, to allow visible type application
    for levity-polymorphic newtypes. As so often, it started simple
    but grew:
    
    * Significant refactor: I removed HsConLikeOut from the
      client-independent Language.Haskell.Syntax.Expr, and put it where it
      belongs, as a new constructor `ConLikeTc` in the GHC-specific extension
      data type for expressions, `GHC.Hs.Expr.XXExprGhcTc`.
    
      That changed touched a lot of files in a very superficial way.
    
    * Note [Typechecking data constructors] explains the main payload.
      The eta-expansion part is no longer done by the typechecker, but
      instead deferred to the desugarer, via `ConLikeTc`
    
    * A little side benefit is that I was able to restore VTA for
      data types with a "stupid theta": #19775.  Not very important,
      but the code in GHC.Tc.Gen.Head.tcInferDataCon is is much, much
      more elegant now.
    
    * I had to refactor the levity-polymorphism checking code in
      GHC.HsToCore.Expr, see
         Note [Checking for levity-polymorphic functions]
         Note [Checking levity-polymorphic data constructors]

Merge request reports