-vectExpr lc (_, AnnLet (AnnNonRec bndr rhs) body)
- = do
- (vrhs, lrhs) <- vectExpr lc rhs
- (vbndr, lbndr, (vbody, lbody)) <- vectBndrIn bndr (vectExpr lc body)
- return (Let (NonRec vbndr vrhs) vbody,
- Let (NonRec lbndr lrhs) lbody)
-vectExpr lc (_, AnnLet (AnnRec prs) body)
- = do
- (vbndrs, lbndrs, (vrhss, vbody, lrhss, lbody)) <- vectBndrsIn bndrs vect
- return (Let (Rec (zip vbndrs vrhss)) vbody,
- Let (Rec (zip lbndrs lrhss)) lbody)
- where
- (bndrs, rhss) = unzip prs
-
- vect = do
- (vrhss, lrhss) <- mapAndUnzipM (vectExpr lc) rhss
- (vbody, lbody) <- vectExpr lc body
- return (vrhss, vbody, lrhss, lbody)
-vectExpr lc (_, AnnLam bndr body)
- | isTyVar bndr
- = do
- pa_ty <- paArgType' (TyVarTy bndr) (tyVarKind bndr)
- pa_var <- newLocalVar FSLIT("dPA") pa_ty
- (vbody, lbody) <- localV
- $ do
- extendTyVarPA bndr (Var pa_var)
- -- FIXME: what about shadowing here (bndr in lc)?
- vectExpr lc body
- return (mkLams [bndr, pa_var] vbody,
- mkLams [bndr, pa_var] lbody)
-
--- ----------------------------------------------------------------------------
--- PA dictionaries
-
-paArgType :: Type -> Kind -> VM (Maybe Type)
-paArgType ty k
- | Just k' <- kindView k = paArgType ty k'
-
--- Here, we assume that for a kind (k1 -> k2) to be valid, k1 and k2 can only
--- be made up of * and (->), i.e., they can't be coercion kinds or #.
-paArgType ty (FunTy k1 k2)
- = do
- tv <- newTyVar FSLIT("a") k1
- ty1 <- paArgType' (TyVarTy tv) k1
- ty2 <- paArgType' (AppTy ty (TyVarTy tv)) k2
- return . Just $ ForAllTy tv (FunTy ty1 ty2)
-
-paArgType ty k
- | isLiftedTypeKind k
- = do
- tc <- builtin paTyCon
- return . Just $ TyConApp tc [ty]