Skip to content

WIP: make plain `x = ..` bindings pat binds not fun binds (#18204)

John Ericson requested to merge Ericson2314/ghc:untangle-fun-pat-binds into master

Fixes #18204. That issue describes the change and motiviation.

The main changes are for the AST in GHC.HS.*. Everything else follows.

Because function binds now have a least one argument, I wanted to use NonEmpty instead of list in MatchGroup. However, pattern synonyms also use MatchGroup, and there is no function bind / pat bind distinction for pattern synonyms, just as there is there none for data constructors. Because of this, I made the functor parameter so I could do MatchGroup NonEmpty or MatchGroup [].

The intended names are MatchGroup, MatchGroup0, and MatchGroup1. But I'll do the mass rename in a separate commit after it works.

The old way is awkward, as evidenced by the number of notes, divergence from the spec, and extraneous strictness field. The new way solves those, and uses NonEmpty to prevent the code from mixing them up.

I did meet up with the earlier-merged !2335 (closed) that cleaned up list -> non-empty from the other end (the desugaring code for matches), but there may be more opportunity to prove away partialities that I didn't find during the rebase of this commit.

CC @int-index

Fixes #18204

Please take a few moments to verify that your commits fulfill the following:

  • are either individually buildable or squashed
  • have commit messages which describe what they do (referring to Notes and tickets using #NNNN syntax when appropriate)
  • have added source comments describing your change. For larger changes you likely should add a Note and cross-reference it from the relevant places.
  • add a testcase to the testsuite.
  • if your MR affects library interfaces (e.g. changes base) or affects whether GHC will accept user-written code, please add the ~"user facing" label.
  • updates the users guide if applicable
  • mentions new features in the release notes for the next release

If you have any questions don't hesitate to open your merge request and inquire in a comment. If your patch isn't quite done yet please do add prefix your MR title with WIP:.

Edited by John Ericson

Merge request reports