From: Matthijs Kooijman Date: Wed, 11 Feb 2009 11:48:36 +0000 (+0100) Subject: Learn flattenExpr about Let expressions. X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fmaster-project%2Fc%CE%BBash.git;a=commitdiff_plain;h=2b45c15cd9100b39789e276bd8a5d7263298b4a9 Learn flattenExpr about Let expressions. --- 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 [])