run lambda parenthesisation recursively inside the body of the lambda

This commit is contained in:
Joey Hess 2013-04-18 14:31:39 -04:00
parent b86712ca80
commit 6ee4c2038e

View file

@ -317,7 +317,8 @@ mangleCode = lambdaparens
- column to the first non-whitespace. This is assumed - column to the first non-whitespace. This is assumed
- to be the expression after the lambda. - 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 lambdaparens = parsecAndReplace $ do
string " \\ " string " \\ "
@ -330,9 +331,12 @@ mangleCode = lambdaparens
char ' ' char ' '
l <- restofline l <- restofline
return $ indent ++ " " ++ l return $ indent ++ " " ++ l
return $ " (\\ " ++ lambdaparams ++ "\n" ++ return $ concat
indent ++ "-> " ++ [ " (\\ " ++ lambdaparams ++ "\n"
intercalate "\n" (firstline:lambdalines) ++ ")\n" , indent ++ "-> "
, lambdaparens $ intercalate "\n" (firstline:lambdalines)
, ")\n"
]
restofline = manyTill (noneOf "\n") newline restofline = manyTill (noneOf "\n") newline