#2431: Allow empty case analysis -------------------------------------------+-------------------------------- Reporter: RalfHinze | Owner: Type: feature request | Status: closed Priority: low | Milestone: _|_ Component: Compiler | Version: 6.8.3 Resolution: fixed | Keywords: empty case analysis Os: Unknown/Multiple | Architecture: Unknown/Multiple Failure: None/Unknown | Difficulty: Unknown Testcase: deSugar/should_compile/T2431 | Blockedby: Blocking: | Related: -------------------------------------------+-------------------------------- Changes (by simonpj):
* status: new => closed * testcase: => deSugar/should_compile/T2431 * resolution: => fixed Comment: Here it is: {{{ commit 3671e674757c8f82ec1f0ea9b7c1ed56340b55bc Author: Simon Peyton Jones <simo...@microsoft.com> Date: Fri Jan 4 10:27:38 2013 +0000 Allow empty case expressions (and lambda-case) with -XEmptyCase The main changes are: * Parser accepts empty case alternatives * Renamer checks that -XEmptyCase is on in that case * (Typechecker is pretty much unchanged.) * Desugarer desugars empty case alternatives, esp: - Match.matchWrapper and Match.match now accept empty eqns - New function matchEmpty deals with the empty case - See Note [Empty case alternatives] in Match This patch contains most of the work, but it's a bit mixed up with a refactoring of MatchGroup that I did at the same time (next commit). compiler/deSugar/DsExpr.lhs | 13 +------- compiler/deSugar/DsUtils.lhs | 2 +- compiler/deSugar/Match.lhs | 55 ++++++++++++++++++++++++++++--------- compiler/deSugar/MatchCon.lhs | 3 +- compiler/deSugar/MatchLit.lhs | 2 +- compiler/main/DynFlags.hs | 4 ++- compiler/parser/Parser.y.pp | 2 + compiler/rename/RnBinds.lhs | 18 ++++++++++-- docs/users_guide/glasgow_exts.xml | 38 +++++++++++++++++++++++++ 9 files changed, 106 insertions(+), 31 deletions(-) }}} but it also needs the follow up {{{ commit a8941e2a4fe3b000e6c085701e0c015c5316c6ee Author: Simon Peyton Jones <simo...@microsoft.com> Date: Fri Jan 4 10:30:14 2013 +0000 Refactor HsExpr.MatchGroup * Make MatchGroup into a record, and use the record fields * Split the type field into two: mg_arg_tys and mg_res_ty This makes life much easier for the desugarer when the case alterantives are empty A little bit of this change unavoidably ended up in the preceding commit about empty case alternatives compiler/deSugar/Coverage.lhs | 12 ++++++------ compiler/deSugar/DsArrows.lhs | 13 ++++++------- compiler/deSugar/DsExpr.lhs | 8 ++++---- compiler/deSugar/DsGRHSs.lhs | 14 +++++++------- compiler/deSugar/DsMeta.hs | 10 +++++----- compiler/hsSyn/HsExpr.lhs | 28 +++++++++++++--------------- compiler/hsSyn/HsUtils.lhs | 2 +- compiler/parser/RdrHsSyn.lhs | 8 ++++---- compiler/rename/RnBinds.lhs | 4 ++-- compiler/rename/RnExpr.lhs | 2 +- compiler/rename/RnTypes.lhs | 2 +- compiler/typecheck/TcArrows.lhs | 9 ++++++--- compiler/typecheck/TcBinds.lhs | 4 ++-- compiler/typecheck/TcHsSyn.lhs | 7 ++++--- compiler/typecheck/TcMatches.lhs | 14 ++++++++------ 15 files changed, 70 insertions(+), 67 deletions(-) }}} and {{{ commit 74d401860d6a28244b9a12fca844fe14a6a04274 Author: Simon Peyton Jones <simo...@microsoft.com> Date: Fri Jan 4 10:30:53 2013 +0000 Switch on -XEmptyCase when renaming derived declarations Compiler-generated code can have empty cases >--------------------------------------------------------------- compiler/typecheck/TcDeriv.lhs | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) }}} -- Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2431#comment:14> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler _______________________________________________ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs