From 2b45c15cd9100b39789e276bd8a5d7263298b4a9 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Wed, 11 Feb 2009 12:48:36 +0100 Subject: [PATCH 1/1] Learn flattenExpr about Let expressions. --- Flatten.hs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Flatten.hs b/Flatten.hs index 7dc261e..20efce5 100644 --- a/Flatten.hs +++ b/Flatten.hs @@ -294,6 +294,17 @@ flattenExpr binds app@(App _ _) = do then error $ "Passing lambda expression or function as a function argument not supported: " ++ (showSDoc $ ppr arg) else flat +flattenExpr binds l@(Let (NonRec b bexpr) expr) = do + (b_args, b_res) <- flattenExpr binds bexpr + if not (null b_args) + then + error $ "Higher order functions not supported in let expression: " ++ (showSDoc $ ppr l) + else + let binds' = (b, Left b_res) : binds in + flattenExpr binds' expr + +flattenExpr binds l@(Let (Rec _) _) = error $ "Recursive let definitions not supported: " ++ (showSDoc $ ppr l) + flattenExpr _ _ = do return ([], Tuple []) -- 2.30.2