summaryrefslogtreecommitdiff
path: root/Build
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-04-16 15:10:23 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-04-16 15:10:23 -0400
commit9589cada839ebc0b6edfb9b319d5d6e12844a536 (patch)
treedde75ee5d58723aab8fa1630a985677cb90281a6 /Build
parent93dc3c40c8549b454a424ea7ac2422060051cde3 (diff)
a few nasty hacks for yesod
Diffstat (limited to 'Build')
-rw-r--r--Build/EvilSplicer.hs18
1 files changed, 17 insertions, 1 deletions
diff --git a/Build/EvilSplicer.hs b/Build/EvilSplicer.hs
index babbb8f72..1fa554b92 100644
--- a/Build/EvilSplicer.hs
+++ b/Build/EvilSplicer.hs
@@ -288,7 +288,11 @@ expandExpressionSplice s lls = concat [before, spliced:padding, end]
{- Tweaks code output by GHC in splices to actually build. Yipes. -}
mangleCode :: String -> String
-mangleCode = nested_instances . fix_bad_escape . remove_package_version
+mangleCode = declaration_parens
+ . remove_declaration_splices
+ . nested_instances
+ . fix_bad_escape
+ . remove_package_version
where
{- GHC may incorrectly escape "}" within a multi-line string. -}
fix_bad_escape = replace " \\}" " }"
@@ -305,6 +309,18 @@ mangleCode = nested_instances . fix_bad_escape . remove_package_version
-}
nested_instances = replace " data instance Route" " data Route"
+ {- GHC does not properly parenthesise generated data type
+ - declarations. -}
+ declaration_parens = replace "StaticR Route Static" "StaticR (Route Static)"
+
+ {- Outright hack: It should remove declaration splices, and does
+ - not, so here I remove the declaration splices used for yesod.
+ -}
+ remove_declaration_splices s
+ | "publicFiles" `isPrefixOf` s = ""
+ | "mkYesodData" `isPrefixOf` s = ""
+ | otherwise = s
+
{- GHC may add full package and version qualifications for
- symbols from unimported modules. We don't want these.
-