-buildPADict :: Var -> TyCon -> TyCon -> VM [(Var, CoreExpr)]
-buildPADict var vect_tc arr_tc
- = localV . abstractOverTyVars (tyConTyVars arr_tc) $ \abstract ->
+buildPAInstance :: TyCon -> TyCon -> VM PAInstance
+buildPAInstance vect_tc arr_tc
+ = do
+ pa <- builtin paClass
+ let inst_ty = mkForAllTys tvs
+ . (mkFunTys $ mkPredTys [ClassP pa [ty] | ty <- arg_tys])
+ $ mkPredTy (ClassP pa [mkTyConApp vect_tc arg_tys])
+
+ dfun <- newExportedVar (mkPADFunOcc $ getOccName vect_tc) inst_ty
+
+ return $ PAInstance {
+ painstInstance = mkLocalInstance dfun NoOverlap
+ , painstVectTyCon = vect_tc
+ , painstArrTyCon = arr_tc
+ }
+ where
+ tvs = tyConTyVars arr_tc
+ arg_tys = mkTyVarTys tvs
+
+buildPADict :: PAInstance -> VM [(Var, CoreExpr)]
+buildPADict (PAInstance {
+ painstInstance = inst
+ , painstVectTyCon = vect_tc
+ , painstArrTyCon = arr_tc })
+ = polyAbstract (tyConTyVars arr_tc) $ \abstract ->