summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2014-05-09 10:59:40 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2014-08-28 11:14:08 +0100
commit8f09937426a40b9c638d63a2d726c3b755f88f82 (patch)
tree329cf1871f5d33825464eb84f064991fa3185bb6 /compiler
parent3af1adf99f1e30a26e540add808d10c2205a2e20 (diff)
downloadhaskell-8f09937426a40b9c638d63a2d726c3b755f88f82.tar.gz
Make maybeUnfoldingTemplate respond to DFunUnfoldings
CoreSyn.maybeUnfoldingTemplate is used mainly when specialising, so make DFunUnfoldings respond to it makes it possible to specialise them properly.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/coreSyn/CoreSyn.lhs11
1 files changed, 9 insertions, 2 deletions
diff --git a/compiler/coreSyn/CoreSyn.lhs b/compiler/coreSyn/CoreSyn.lhs
index f16e53d6ca..e82303c4ae 100644
--- a/compiler/coreSyn/CoreSyn.lhs
+++ b/compiler/coreSyn/CoreSyn.lhs
@@ -869,9 +869,16 @@ unfoldingTemplate :: Unfolding -> CoreExpr
unfoldingTemplate = uf_tmpl
-- | Retrieves the template of an unfolding if possible
+-- maybeUnfoldingTemplate is used mainly wnen specialising, and we do
+-- want to specialise DFuns, so it's important to return a template
+-- for DFunUnfoldings
maybeUnfoldingTemplate :: Unfolding -> Maybe CoreExpr
-maybeUnfoldingTemplate (CoreUnfolding { uf_tmpl = expr }) = Just expr
-maybeUnfoldingTemplate _ = Nothing
+maybeUnfoldingTemplate (CoreUnfolding { uf_tmpl = expr })
+ = Just expr
+maybeUnfoldingTemplate (DFunUnfolding { df_bndrs = bndrs, df_con = con, df_args = args })
+ = Just (mkLams bndrs (mkApps (Var (dataConWorkId con)) args))
+maybeUnfoldingTemplate _
+ = Nothing
-- | The constructors that the unfolding could never be:
-- returns @[]@ if no information is available