aboutsummaryrefslogtreecommitdiff
path: root/Build/EvilSplicer.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-09-22 20:34:20 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-09-22 20:34:20 -0400
commit440c9747360294852f8fd74658cf2fcebb84c6c9 (patch)
treec3b7c9c92f0b448d811967e77c2f8c4b6c2d8e25 /Build/EvilSplicer.hs
parent53038c3385f7ed31105650fbe5f03310fa87aefe (diff)
one more EvilSplicer hack for the night
Diffstat (limited to 'Build/EvilSplicer.hs')
-rw-r--r--Build/EvilSplicer.hs36
1 files changed, 36 insertions, 0 deletions
diff --git a/Build/EvilSplicer.hs b/Build/EvilSplicer.hs
index 11ab7612b..442ac5952 100644
--- a/Build/EvilSplicer.hs
+++ b/Build/EvilSplicer.hs
@@ -295,6 +295,7 @@ expandExpressionSplice s lls = concat [before, spliced:padding, end]
mangleCode :: String -> String
mangleCode = flip_colon
. remove_unnecessary_type_signatures
+ . lambdaparenhack
. lambdaparens
. declaration_parens
. case_layout
@@ -354,6 +355,41 @@ mangleCode = flip_colon
, lambdaparens $ intercalate "\n" (firstline:lambdalines)
, ")\n"
]
+
+ {- Hack to add missing parens in a specific case in yesod
+ - static route code.
+ -
+ - StaticR
+ - yesod_dispatch_env_a4iDV
+ - (\ p_a4iE2 r_a4iE3
+ - -> r_a4iE3 {Network.Wai.pathInfo = p_a4iE2}
+ - xrest_a4iDT req_a4iDW)) }
+ -
+ - Need to add another paren around the lambda, and close it
+ - before its parameters. lambdaparens misses this one because
+ - there is already one paren present.
+ -
+ - FIXME: This is a hack. lambdaparens could just always add a
+ - layer of parens even when a lambda seems to be in parent.
+ -}
+ lambdaparenhack = parsecAndReplace $ do
+ indent <- many1 $ char ' '
+ staticr <- string "StaticR"
+ newline
+ string indent
+ yesod_dispatch_env <- restofline
+ string indent
+ lambdaprefix <- string "(\\ "
+ l1 <- restofline
+ string indent
+ lambdaarrow <- string " ->"
+ l2 <- restofline
+ return $ unlines
+ [ indent, staticr
+ , indent, yesod_dispatch_env
+ , indent, "(", lambdaprefix, l1
+ , indent, lambdaarrow, l2, ")"
+ ]
restofline = manyTill (noneOf "\n") newline