one more EvilSplicer hack for the night
This commit is contained in:
parent
8375e5f06d
commit
746d3d5e1f
1 changed files with 36 additions and 0 deletions
|
@ -295,6 +295,7 @@ expandExpressionSplice s lls = concat [before, spliced:padding, end]
|
||||||
mangleCode :: String -> String
|
mangleCode :: String -> String
|
||||||
mangleCode = flip_colon
|
mangleCode = flip_colon
|
||||||
. remove_unnecessary_type_signatures
|
. remove_unnecessary_type_signatures
|
||||||
|
. lambdaparenhack
|
||||||
. lambdaparens
|
. lambdaparens
|
||||||
. declaration_parens
|
. declaration_parens
|
||||||
. case_layout
|
. case_layout
|
||||||
|
@ -355,6 +356,41 @@ mangleCode = flip_colon
|
||||||
, ")\n"
|
, ")\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
|
restofline = manyTill (noneOf "\n") newline
|
||||||
|
|
||||||
{- For some reason, GHC sometimes doesn't like the multiline
|
{- For some reason, GHC sometimes doesn't like the multiline
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue