- theta, orig_arg_tys) = dataConFullSig data_con
- tycon = dataConTyCon data_con
-
- ----------- Wrapper --------------
- -- We used to include the stupid theta in the wrapper's args
- -- but now we don't. Instead the type checker just injects these
- -- extra constraints where necessary.
- wrap_tvs = (univ_tvs `minusList` map fst eq_spec) ++ ex_tvs
- subst = mkTopTvSubst eq_spec
- famSubst = ASSERT( length (tyConTyVars tycon ) ==
- length (mkTyVarTys univ_tvs) )
- zipTopTvSubst (tyConTyVars tycon) (mkTyVarTys univ_tvs)
- -- substitution mapping the type constructor's type
- -- arguments to the universals of the data constructor
- -- (crucial when type checking interfaces)
- dict_tys = mkPredTys theta
- result_ty_args = map (substTyVar subst) univ_tvs
- result_ty = case tyConFamInst_maybe tycon of
- -- ordinary constructor
- Nothing -> mkTyConApp tycon result_ty_args
- -- family instance constructor
- Just (familyTyCon,
- instTys) ->
- mkTyConApp familyTyCon ( substTys subst
- . substTys famSubst
- $ instTys)
- wrap_ty = mkForAllTys wrap_tvs $ mkFunTys dict_tys $
- mkFunTys orig_arg_tys $ result_ty
- -- NB: watch out here if you allow user-written equality
- -- constraints in data constructor signatures
-
- ----------- Worker (algebraic data types only) --------------
- -- The *worker* for the data constructor is the function that
- -- takes the representation arguments and builds the constructor.
+ eq_theta, dict_theta, orig_arg_tys, res_ty) = dataConFullSig data_con
+ tycon = dataConTyCon data_con -- The representation TyCon (not family)
+
+ ----------- Worker (algebraic data types only) --------------
+ -- The *worker* for the data constructor is the function that
+ -- takes the representation arguments and builds the constructor.