summaryrefslogtreecommitdiff
path: root/Build
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-04-17 00:45:55 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-04-17 00:51:29 -0400
commit48c38c3849d67f19c2188a30503acdced726ef2b (patch)
tree2a120d642cf01a966645e04ce12e57a5d9f7a5a1 /Build
parentb89ff59fc0e94276bbd871abb4c814338d073d1d (diff)
very close now.. but still so far
Diffstat (limited to 'Build')
-rw-r--r--Build/EvilSplicer.hs33
1 files changed, 25 insertions, 8 deletions
diff --git a/Build/EvilSplicer.hs b/Build/EvilSplicer.hs
index a1622dd59..b717b5621 100644
--- a/Build/EvilSplicer.hs
+++ b/Build/EvilSplicer.hs
@@ -297,6 +297,7 @@ mangleCode = declaration_parens
. nested_instances
. collapse_multiline_strings
. remove_package_version
+ . emptylambda
where
{- For some reason, GHC sometimes doesn't like the multiline
- strings it creates. It seems to get hung up on \{ at the
@@ -339,11 +340,13 @@ mangleCode = declaration_parens
newline
indent <- many1 $ char ' '
prefix <- manyTill (noneOf "\n") (try (string "-> "))
- if "\\ " `isInfixOf` prefix
- then unexpected "lambda expression"
- else if null prefix
- then unexpected "second line of lambda"
- else return $ "\n" ++ indent ++ "; " ++ prefix ++ " -> "
+ if length prefix > 10
+ then unexpected "too long a prefix"
+ else if "\\ " `isInfixOf` prefix
+ then unexpected "lambda expression"
+ else if null prefix
+ then unexpected "second line of lambda"
+ else return $ "\n" ++ indent ++ "; " ++ prefix ++ " -> "
{- Sometimes cases themselves span multiple lines:
-
- Nothing
@@ -362,6 +365,14 @@ mangleCode = declaration_parens
else return $ "\n" ++ indent ++ "; " ++ firstline ++ "\n"
++ indent ++ indent2 ++ "-> "
+ {- (foo, \ -> bar) is not valid haskell, GHC.
+ - Change to (foo, bar)
+ -
+ - (Does this ever happen outside a tuple? Only saw
+ - it inside them..
+ -}
+ emptylambda = replace ", \\ -> " ", "
+
{- GHC may output this:
-
- instance RenderRoute WebApp where
@@ -402,12 +413,18 @@ mangleCode = declaration_parens
qualifiedSymbol :: Parser String
qualifiedSymbol = do
- token
+ s <- token
char ':'
- token
+ if length s < 5
+ then unexpected "too short to be a namespace"
+ else do
+ token
token :: Parser String
- token = many1 $ satisfy isAlphaNum <|> oneOf "-.'"
+ token = do
+ t <- satisfy isLetter
+ oken <- many $ satisfy isAlphaNum <|> oneOf "-.'"
+ return $ t:oken
{- This works around a problem in the expanded template haskell for Yesod's
- static site route rendering.