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. stuff Implement empty one of Prohibit TyApps Remove unused update submodule haddock Update tests Parser.y
parent
ee93edfd
No related branches found
No related tags found
Pipeline #82213 failed
Stage: tool-lint
Stage: quick-build
Stage: full-build
Stage: packaging
Stage: testing
Showing
- compiler/GHC/Driver/Session.hs 1 addition, 0 deletionscompiler/GHC/Driver/Session.hs
- compiler/GHC/Hs/Pat.hs 34 additions, 0 deletionscompiler/GHC/Hs/Pat.hs
- compiler/GHC/Hs/Syn/Type.hs 1 addition, 0 deletionscompiler/GHC/Hs/Syn/Type.hs
- compiler/GHC/Hs/Utils.hs 3 additions, 0 deletionscompiler/GHC/Hs/Utils.hs
- compiler/GHC/HsToCore/Match.hs 55 additions, 15 deletionscompiler/GHC/HsToCore/Match.hs
- compiler/GHC/HsToCore/Pmc/Check.hs 44 additions, 21 deletionscompiler/GHC/HsToCore/Pmc/Check.hs
- compiler/GHC/HsToCore/Pmc/Desugar.hs 63 additions, 59 deletionscompiler/GHC/HsToCore/Pmc/Desugar.hs
- compiler/GHC/HsToCore/Pmc/Types.hs 57 additions, 7 deletionscompiler/GHC/HsToCore/Pmc/Types.hs
- compiler/GHC/HsToCore/Utils.hs 41 additions, 22 deletionscompiler/GHC/HsToCore/Utils.hs
- compiler/GHC/Iface/Ext/Ast.hs 2 additions, 0 deletionscompiler/GHC/Iface/Ext/Ast.hs
- compiler/GHC/Parser.y 36 additions, 5 deletionscompiler/GHC/Parser.y
- compiler/GHC/Parser/Annotation.hs 1 addition, 0 deletionscompiler/GHC/Parser/Annotation.hs
- compiler/GHC/Parser/Errors/Ppr.hs 6 additions, 0 deletionscompiler/GHC/Parser/Errors/Ppr.hs
- compiler/GHC/Parser/Errors/Types.hs 3 additions, 0 deletionscompiler/GHC/Parser/Errors/Types.hs
- compiler/GHC/Parser/Lexer.x 4 additions, 0 deletionscompiler/GHC/Parser/Lexer.x
- compiler/GHC/Parser/PostProcess.hs 34 additions, 13 deletionscompiler/GHC/Parser/PostProcess.hs
- compiler/GHC/Rename/Bind.hs 1 addition, 0 deletionscompiler/GHC/Rename/Bind.hs
- compiler/GHC/Rename/Expr.hs 1 addition, 0 deletionscompiler/GHC/Rename/Expr.hs
- compiler/GHC/Rename/Pat.hs 9 additions, 0 deletionscompiler/GHC/Rename/Pat.hs
- compiler/GHC/Tc/Errors/Ppr.hs 13 additions, 0 deletionscompiler/GHC/Tc/Errors/Ppr.hs
Loading
Please register or sign in to comment