- = polyAbstract tvs $ \args ->
- do
- method_ids <- mapM (method args) paMethods
-
- pa_tc <- builtin paTyCon
+ = polyAbstract tvs $ \args ->
+ do
+ -- The superclass dictionary is an argument if the tycon is polymorphic
+ let mk_super_ty = do
+ r <- mkPReprType inst_ty
+ pr_cls <- builtin prClass
+ return $ PredTy $ ClassP pr_cls [r]
+ super_tys <- sequence [mk_super_ty | not (null tvs)]
+ super_args <- mapM (newLocalVar (fsLit "pr")) super_tys
+ let args' = super_args ++ args
+
+ -- it is constant otherwise
+ super_consts <- sequence [prDictOfPReprInstTyCon inst_ty prepr_tc []
+ | null tvs]
+
+ -- Get ids for each of the methods in the dictionary.
+ method_ids <- mapM (method args') paMethods
+
+ -- Expression to build the dictionary.