diff options
author | Roman Leshchinskiy <rl@cse.unsw.edu.au> | 2007-07-11 04:48:20 +0000 |
---|---|---|
committer | Roman Leshchinskiy <rl@cse.unsw.edu.au> | 2007-07-11 04:48:20 +0000 |
commit | 8e44e777ea4bf3595c15388fa633b45e2285472f (patch) | |
tree | 4b2fc057b5d25d50a3cfb68e50536ec8cb03e24a | |
parent | 39466c4fe6d9e49f5000b113f7fda4c9afcfb592 (diff) | |
download | haskell-8e44e777ea4bf3595c15388fa633b45e2285472f.tar.gz |
Refactoring
-rw-r--r-- | compiler/vectorise/Vectorise.hs | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/compiler/vectorise/Vectorise.hs b/compiler/vectorise/Vectorise.hs index e533650d58..6ac3d48517 100644 --- a/compiler/vectorise/Vectorise.hs +++ b/compiler/vectorise/Vectorise.hs @@ -130,29 +130,33 @@ vectPolyVar lc v tys return $ mkApps e [arg | (vty, dict) <- zip vtys dicts , arg <- [Type vty, dict]] -vectPolyExpr :: CoreExpr -> CoreExprWithFVs -> VM (CoreExpr, CoreExpr) -vectPolyExpr lc expr +abstractOverTyVars :: [TyVar] -> ((CoreExpr -> CoreExpr) -> VM a) -> VM a +abstractOverTyVars tvs p = do mdicts <- mapM mk_dict_var tvs - - -- FIXME: shadowing (tvs in lc) - (vmono, lmono) <- localV - $ do - zipWithM_ (\tv -> maybe (deleteTyVarPA tv) (extendTyVarPA tv . Var)) - tvs mdicts - vectExpr lc mono - return (mk_lams tvs mdicts vmono, mk_lams tvs mdicts lmono) + zipWithM_ (\tv -> maybe (deleteTyVarPA tv) (extendTyVarPA tv . Var)) tvs mdicts + p (mk_lams mdicts) where - (tvs, mono) = collectAnnTypeBinders expr - mk_dict_var tv = do r <- paDictArgType tv case r of Just ty -> liftM Just (newLocalVar FSLIT("dPA") ty) Nothing -> return Nothing - mk_lams tvs mdicts = mkLams [arg | (tv, mdict) <- zip tvs mdicts - , arg <- tv : maybeToList mdict] + mk_lams mdicts = mkLams [arg | (tv, mdict) <- zip tvs mdicts + , arg <- tv : maybeToList mdict] + + +vectPolyExpr :: CoreExpr -> CoreExprWithFVs -> VM (CoreExpr, CoreExpr) +vectPolyExpr lc expr + = localV + . abstractOverTyVars tvs $ \mk_lams -> + -- FIXME: shadowing (tvs in lc) + do + (vmono, lmono) <- vectExpr lc mono + return $ (mk_lams vmono, mk_lams lmono) + where + (tvs, mono) = collectAnnTypeBinders expr vectExpr :: CoreExpr -> CoreExprWithFVs -> VM (CoreExpr, CoreExpr) vectExpr lc (_, AnnType ty) |