avoid adding parens to lambdas in tuples
This commit is contained in:
parent
6ee4c2038e
commit
715e68ad58
1 changed files with 13 additions and 3 deletions
|
@ -290,7 +290,8 @@ expandExpressionSplice s lls = concat [before, spliced:padding, end]
|
||||||
|
|
||||||
{- Tweaks code output by GHC in splices to actually build. Yipes. -}
|
{- Tweaks code output by GHC in splices to actually build. Yipes. -}
|
||||||
mangleCode :: String -> String
|
mangleCode :: String -> String
|
||||||
mangleCode = lambdaparens
|
mangleCode = flip_colon
|
||||||
|
. lambdaparens
|
||||||
. declaration_parens
|
. declaration_parens
|
||||||
. case_layout
|
. case_layout
|
||||||
. case_layout_multiline
|
. case_layout_multiline
|
||||||
|
@ -321,7 +322,10 @@ mangleCode = lambdaparens
|
||||||
- lambdas.
|
- lambdas.
|
||||||
-}
|
-}
|
||||||
lambdaparens = parsecAndReplace $ do
|
lambdaparens = parsecAndReplace $ do
|
||||||
string " \\ "
|
-- skip lambdas inside tuples or parens
|
||||||
|
prefix <- noneOf "(, \n"
|
||||||
|
preindent <- many1 $ oneOf " \n"
|
||||||
|
string "\\ "
|
||||||
lambdaparams <- restofline
|
lambdaparams <- restofline
|
||||||
indent <- many1 $ char ' '
|
indent <- many1 $ char ' '
|
||||||
string "-> "
|
string "-> "
|
||||||
|
@ -332,7 +336,8 @@ mangleCode = lambdaparens
|
||||||
l <- restofline
|
l <- restofline
|
||||||
return $ indent ++ " " ++ l
|
return $ indent ++ " " ++ l
|
||||||
return $ concat
|
return $ concat
|
||||||
[ " (\\ " ++ lambdaparams ++ "\n"
|
[ prefix:preindent
|
||||||
|
, "(\\ " ++ lambdaparams ++ "\n"
|
||||||
, indent ++ "-> "
|
, indent ++ "-> "
|
||||||
, lambdaparens $ intercalate "\n" (firstline:lambdalines)
|
, lambdaparens $ intercalate "\n" (firstline:lambdalines)
|
||||||
, ")\n"
|
, ")\n"
|
||||||
|
@ -459,6 +464,11 @@ mangleCode = lambdaparens
|
||||||
oken <- many $ satisfy isAlphaNum <|> oneOf "-.'"
|
oken <- many $ satisfy isAlphaNum <|> oneOf "-.'"
|
||||||
return $ t:oken
|
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
|
{- This works around a problem in the expanded template haskell for Yesod
|
||||||
- type-safe url rendering.
|
- type-safe url rendering.
|
||||||
-
|
-
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue