- 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 = substTyVars 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