summaryrefslogtreecommitdiff
path: root/compiler/deSugar/DsExpr.lhs
diff options
context:
space:
mode:
authorMikhail Vorozhtsov <mikhail.vorozhtsov@gmail.com>2011-04-23 12:06:38 +0700
committerSimon Marlow <marlowsd@gmail.com>2012-07-16 11:09:35 +0100
commitb1e97f2f325537664f09eee7ea0e7c53264b061e (patch)
tree3e66009147692d7dfb408325c431c8f5a126d798 /compiler/deSugar/DsExpr.lhs
parentc1f01e351759e7c25818b05e32bdb7b702dac6f2 (diff)
downloadhaskell-b1e97f2f325537664f09eee7ea0e7c53264b061e.tar.gz
Implemented \case expressions.
Diffstat (limited to 'compiler/deSugar/DsExpr.lhs')
-rw-r--r--compiler/deSugar/DsExpr.lhs9
1 files changed, 9 insertions, 0 deletions
diff --git a/compiler/deSugar/DsExpr.lhs b/compiler/deSugar/DsExpr.lhs
index 11fa5d53c9..4795b5f68c 100644
--- a/compiler/deSugar/DsExpr.lhs
+++ b/compiler/deSugar/DsExpr.lhs
@@ -205,6 +205,15 @@ dsExpr (NegApp expr neg_expr)
dsExpr (HsLam a_Match)
= uncurry mkLams <$> matchWrapper LambdaExpr a_Match
+dsExpr (HsLamCase arg matches@(MatchGroup _ rhs_ty))
+ | isEmptyMatchGroup matches -- A Core 'case' is always non-empty
+ = -- So desugar empty HsLamCase to error call
+ mkErrorAppDs pAT_ERROR_ID (funResultTy rhs_ty) (ptext (sLit "\\case"))
+ | otherwise
+ = do { arg_var <- newSysLocalDs arg
+ ; ([discrim_var], matching_code) <- matchWrapper CaseAlt matches
+ ; return $ Lam arg_var $ bindNonRec discrim_var (Var arg_var) matching_code }
+
dsExpr (HsApp fun arg)
= mkCoreAppDs <$> dsLExpr fun <*> dsLExpr arg
\end{code}