From 17852552fb024c01f8f8d76c8668c5327c32d4ff Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Sun, 21 Jun 2009 18:09:20 +0200 Subject: [PATCH] Add an empty let before starting normalization. This ensures that every expression will always contain a let at the top level, since none of the transforms will remove the last let (lets are only merged when two are nested). --- Normalize.hs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Normalize.hs b/Normalize.hs index 93e89b6..57af912 100644 --- a/Normalize.hs +++ b/Normalize.hs @@ -442,6 +442,10 @@ normalizeBind bndr = do expr_maybe <- getGlobalBind bndr case expr_maybe of Just expr -> do + -- Introduce an empty Let at the top level, so there will always be + -- a let in the expression (none of the transformations will remove + -- the last let). + let expr' = Let (Rec []) expr -- Normalize this expression trace ("Transforming " ++ (show bndr) ++ "\nBefore:\n\n" ++ showSDoc ( ppr expr ) ++ "\n") $ return () expr' <- dotransforms transforms expr -- 2.30.2