- = case mb_sig of
- Nothing -> do { prags <- tcPrags poly_id (prag_fn poly_name)
- ; return (inferred_tvs, poly_id, mono_id, prags) }
- where
- poly_id = mkLocalId poly_name poly_ty
- poly_ty = mkForAllTys inferred_tvs
- $ mkFunTys dict_tys
- $ idType mono_id
-
- Just sig -> do { let poly_id = sig_id sig
- ; prags <- tcPrags poly_id (prag_fn poly_name)
- ; sig_tys <- zonkTcTyVars (sig_tvs sig)
- ; let sig_tvs' = map (tcGetTyVar "mkExport") sig_tys
- ; return (sig_tvs', poly_id, mono_id, prags) }
- -- We zonk the sig_tvs here so that the export triple
- -- always has zonked type variables;
- -- a convenient invariant
+ = do { (tvs, poly_id) <- mk_poly_id mb_sig
+
+ ; poly_id' <- zonkId poly_id
+ ; prags <- tcPrags poly_id' (prag_fn poly_name)
+ -- tcPrags requires a zonked poly_id
+
+ ; return (tvs, poly_id', mono_id, prags) }
+ where
+ poly_ty = mkForAllTys inferred_tvs (mkFunTys dict_tys (idType mono_id))
+
+ mk_poly_id Nothing = return (inferred_tvs, mkLocalId poly_name poly_ty)
+ mk_poly_id (Just sig) = do { tvs <- mapM zonk_tv (sig_tvs sig)
+ ; return (tvs, sig_id sig) }