From 8f09937426a40b9c638d63a2d726c3b755f88f82 Mon Sep 17 00:00:00 2001 From: Simon Peyton Jones Date: Fri, 9 May 2014 10:59:40 +0100 Subject: 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. --- compiler/coreSyn/CoreSyn.lhs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'compiler') 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 -- cgit v1.2.1