summaryrefslogtreecommitdiff
path: root/Build
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-04-18 14:56:36 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-04-18 15:07:29 -0400
commit6679b75c9d8d7cf262035d96bfd298a4d91f8644 (patch)
tree745c4b347e0751250fdeb21957ea5224a660de6f /Build
parent581ac9a562fd4286b284663bcffb6be23f73ab57 (diff)
avoid adding parens to lambdas in tuples
Diffstat (limited to 'Build')
-rw-r--r--Build/EvilSplicer.hs16
1 files changed, 13 insertions, 3 deletions
diff --git a/Build/EvilSplicer.hs b/Build/EvilSplicer.hs
index b46a1a63f..a43a971fd 100644
--- a/Build/EvilSplicer.hs
+++ b/Build/EvilSplicer.hs
@@ -290,7 +290,8 @@ expandExpressionSplice s lls = concat [before, spliced:padding, end]
{- Tweaks code output by GHC in splices to actually build. Yipes. -}
mangleCode :: String -> String
-mangleCode = lambdaparens
+mangleCode = flip_colon
+ . lambdaparens
. declaration_parens
. case_layout
. case_layout_multiline
@@ -321,7 +322,10 @@ mangleCode = lambdaparens
- lambdas.
-}
lambdaparens = parsecAndReplace $ do
- string " \\ "
+ -- skip lambdas inside tuples or parens
+ prefix <- noneOf "(, \n"
+ preindent <- many1 $ oneOf " \n"
+ string "\\ "
lambdaparams <- restofline
indent <- many1 $ char ' '
string "-> "
@@ -332,7 +336,8 @@ mangleCode = lambdaparens
l <- restofline
return $ indent ++ " " ++ l
return $ concat
- [ " (\\ " ++ lambdaparams ++ "\n"
+ [ prefix:preindent
+ , "(\\ " ++ lambdaparams ++ "\n"
, indent ++ "-> "
, lambdaparens $ intercalate "\n" (firstline:lambdalines)
, ")\n"
@@ -459,6 +464,11 @@ mangleCode = lambdaparens
oken <- many $ satisfy isAlphaNum <|> oneOf "-.'"
return $ t:oken
+ {- This works when it's "GHC.Types.:", but we strip
+ - that above, so have to fix up after it here.
+ - The ; is added by case_layout. -}
+ flip_colon = replace "; : _ " "; _ : "
+
{- This works around a problem in the expanded template haskell for Yesod
- type-safe url rendering.
-