From 6ee4c2038e594541cd9905f05f16d85261753060 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 18 Apr 2013 14:31:39 -0400 Subject: [PATCH] run lambda parenthesisation recursively inside the body of the lambda --- Build/EvilSplicer.hs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Build/EvilSplicer.hs b/Build/EvilSplicer.hs index d505182449..b46a1a63f9 100644 --- a/Build/EvilSplicer.hs +++ b/Build/EvilSplicer.hs @@ -317,7 +317,8 @@ mangleCode = lambdaparens - column to the first non-whitespace. This is assumed - to be the expression after the lambda. - - - This does not handle nested unparenthesised lambdas. + - Runs recursively on the body of the lambda, to handle nested + - lambdas. -} lambdaparens = parsecAndReplace $ do string " \\ " @@ -330,9 +331,12 @@ mangleCode = lambdaparens char ' ' l <- restofline return $ indent ++ " " ++ l - return $ " (\\ " ++ lambdaparams ++ "\n" ++ - indent ++ "-> " ++ - intercalate "\n" (firstline:lambdalines) ++ ")\n" + return $ concat + [ " (\\ " ++ lambdaparams ++ "\n" + , indent ++ "-> " + , lambdaparens $ intercalate "\n" (firstline:lambdalines) + , ")\n" + ] restofline = manyTill (noneOf "\n") newline