[Git][ghc/ghc][wip/or-pats-match] 9 commits: Implement Or Patterns (Proposal 0522)

David (@knothed) gitlab at gitlab.haskell.org
Mon Jun 19 10:46:56 UTC 2023



David pushed to branch wip/or-pats-match at Glasgow Haskell Compiler / GHC


Commits:
062a5a03 by David Knothe at 2023-06-01T11:19:36+02:00
Implement Or Patterns (Proposal 0522)

This commit introduces a language extension, `OrPatterns`, as described in proposal 0522.

It extends the syntax by the production
`pat -> (one of pat1, ..., patk)`.
The or-pattern `pat` succeeds iff one of the patterns `pat1`, ..., `patk` succeed, in this order.

Currently, or-patterns cannot bind variables. They are still of great use as they discourage the use of wildcard patterns in favour of writing out all "default" cases explicitly:

```
isIrrefutableHsPat pat = case pat of
  ...
  (one of WildPat{}, VarPat{}, LazyPat{})
      = True
  (one of PArrPat{}, ConPatIn{}, LitPat{}, NPat{}, NPlusKPat{}, ListPat{})
      = False
```

This makes code safer where data types are extended now and then - just like GHC's `Pat` in the example when adding the new `OrPat` constructor. This would be catched by `-fwarn-incomplete-patterns`, but not when a wildcard pattern was used.

- Update submodule haddock.

- - - - -
2369239f by David Knothe at 2023-06-01T11:19:38+02:00
stuff

- - - - -
d5137966 by David Knothe at 2023-06-01T11:19:39+02:00
Implement empty one of

- - - - -
1838cc63 by David Knothe at 2023-06-01T11:21:49+02:00
Prohibit TyApps

- - - - -
c6ae3f49 by David Knothe at 2023-06-01T11:21:50+02:00
Remove unused

- - - - -
a0155c1e by David Knothe at 2023-06-01T11:21:50+02:00
update submodule haddock

- - - - -
24c5f66b by David Knothe at 2023-06-01T11:21:50+02:00
Update tests

- - - - -
c93c3ddd by David Knothe at 2023-06-09T14:23:36+02:00
Play around with Match

- - - - -
b23a7d4a by David Knothe at 2023-06-19T12:43:03+02:00
wip: OrPat match impl

- - - - -


30 changed files:

- + a.out
- compiler/GHC/Driver/Session.hs
- compiler/GHC/Hs/Pat.hs
- compiler/GHC/Hs/Syn/Type.hs
- compiler/GHC/Hs/Utils.hs
- compiler/GHC/HsToCore/Expr.hs
- compiler/GHC/HsToCore/Match.hs
- compiler/GHC/HsToCore/Match.hs-boot
- compiler/GHC/HsToCore/Match/Constructor.hs
- compiler/GHC/HsToCore/Match/Literal.hs
- compiler/GHC/HsToCore/Monad.hs
- compiler/GHC/HsToCore/Pmc/Check.hs
- compiler/GHC/HsToCore/Pmc/Desugar.hs
- compiler/GHC/HsToCore/Pmc/Types.hs
- compiler/GHC/HsToCore/Utils.hs
- compiler/GHC/Iface/Ext/Ast.hs
- compiler/GHC/Parser.y
- compiler/GHC/Parser/Annotation.hs
- compiler/GHC/Parser/Errors/Ppr.hs
- compiler/GHC/Parser/Errors/Types.hs
- compiler/GHC/Parser/Lexer.x
- compiler/GHC/Parser/PostProcess.hs
- compiler/GHC/Rename/Bind.hs
- compiler/GHC/Rename/Expr.hs
- compiler/GHC/Rename/Pat.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Errors/Types.hs
- compiler/GHC/Tc/Gen/Pat.hs
- compiler/GHC/Tc/TyCl/PatSyn.hs
- compiler/GHC/Tc/Utils/Zonk.hs


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/89bb8ad8b5fa56b83fe80dd6d7147ad81ae4e74d...b23a7d4aed173efa2f13a841f32da6832f942b13

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/89bb8ad8b5fa56b83fe80dd6d7147ad81ae4e74d...b23a7d4aed173efa2f13a841f32da6832f942b13
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230619/3668a998/attachment.html>


More information about the ghc-commits mailing list