Skip to content

Expand `do` blocks before typechecking (towards killing tcSyntaxOp)

Apoorv Ingle requested to merge wip/expand-do into master

Fixes for #18324 (closed) #20020 (closed) #23147 (closed) #22788 (closed) #15598 (closed) #22086 (closed) (and few more that I need to search for). Maybe #24218.

This is part of killing tcSyntaxOp and enabling Impredicativity for do statments.

  1. Expands Vanilla/Monadic Do notation into binds before desugaring.
  2. Makes sure Debugging semantics is maintained.
  3. The commit also includes a (big) Note [Expanding HsDo with HsExpansion] in GHC.Tc.Gen.Match

This fix does not include expanding applicative do or mdo as their raw AST structure is ill-suited for generating proper error messages. We also cannot get rid of any portion of tcSyntaxOp or desugaring HsDo in GHC.HsToCore.

This change however is quite big and adding more things to this MR might potentially be pain to review.

Edited by Simon Peyton Jones

Merge request reports