From a879bbd83d5ce95e0d05aa117819edf88bc8f6d4 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Thu, 16 Apr 2009 10:00:14 +0200 Subject: [PATCH] Support binding the scrutinee of a Case expression. --- Flatten.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Flatten.hs b/Flatten.hs index 74b3232..8c4c7ab 100644 --- a/Flatten.hs +++ b/Flatten.hs @@ -268,11 +268,12 @@ flattenExpr binds expr@(Case scrut b _ alts) = do -- TODO: Special casing for higher order functions -- Flatten the scrutinee (_, res) <- flattenExpr binds scrut + -- Put the scrutinee in the BindMap + let binds' = (b, Left res) : binds case alts of - -- TODO include b in the binds list - [alt] -> flattenSingleAltCaseExpr binds res b alt + [alt] -> flattenSingleAltCaseExpr binds' res b alt -- Reverse the alternatives, so the __DEFAULT alternative ends up last - otherwise -> flattenMultipleAltCaseExpr binds res b (reverse alts) + otherwise -> flattenMultipleAltCaseExpr binds' res b (reverse alts) where flattenSingleAltCaseExpr :: BindMap -- 2.30.2