summaryrefslogtreecommitdiff
path: root/compiler/typecheck/TcExpr.hs
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2015-08-05 14:24:54 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2015-08-05 16:50:41 +0100
commit953648127cea2836ec134b03a966695ac0b36434 (patch)
tree6b5721dc6f0133b54af97c60f396e9207ef223ae /compiler/typecheck/TcExpr.hs
parentab98860871cfac17417d5b55e590445064d21111 (diff)
downloadhaskell-953648127cea2836ec134b03a966695ac0b36434.tar.gz
Tidy up and refactor wildcard handling
When examining #10615, I found the wildcard handling hard to understand. This patch refactors quite a bit, but with no real change in behaviour. * Split out TcIdSigInfo from TcSigInfo, as a separate type, like TcPatSynInfo. * Make TcIdSigInfo express more invariants by pushing the wildard info into TcIdSigBndr * Remove all special treatment of unification variables that arise from wildcards; so the TauTv of TcType.MetaInfo loses its Bool argument. A ton of konck on changes. The result is significantly simpler, I think.
Diffstat (limited to 'compiler/typecheck/TcExpr.hs')
-rw-r--r--compiler/typecheck/TcExpr.hs11
1 files changed, 5 insertions, 6 deletions
diff --git a/compiler/typecheck/TcExpr.hs b/compiler/typecheck/TcExpr.hs
index 605ba57089..d2b0c59244 100644
--- a/compiler/typecheck/TcExpr.hs
+++ b/compiler/typecheck/TcExpr.hs
@@ -218,9 +218,10 @@ tcExpr e@(HsLamCase _ matches) res_ty
match_ctxt = MC { mc_what = CaseAlt, mc_body = tcBody }
tcExpr (ExprWithTySig expr sig_ty wcs) res_ty
- = do { nwc_tvs <- mapM newWildcardVarMetaKind wcs
- ; tcExtendTyVarEnv nwc_tvs $ do {
- sig_tc_ty <- tcHsSigType ExprSigCtxt sig_ty
+ = tcWildcardBinders wcs $ \ wc_prs ->
+ do { addErrCtxt (pprSigCtxt ExprSigCtxt empty (ppr sig_ty)) $
+ emitWildcardHoleConstraints wc_prs
+ ; sig_tc_ty <- tcHsSigType ExprSigCtxt sig_ty
; (gen_fn, expr')
<- tcGen ExprSigCtxt sig_tc_ty $ \ skol_tvs res_ty ->
@@ -234,9 +235,7 @@ tcExpr (ExprWithTySig expr sig_ty wcs) res_ty
; let inner_expr = ExprWithTySigOut (mkLHsWrap gen_fn expr') sig_ty
; (inst_wrap, rho) <- deeplyInstantiate ExprSigOrigin sig_tc_ty
- ; addErrCtxt (pprSigCtxt ExprSigCtxt empty (ppr sig_ty)) $
- emitWildcardHoleConstraints (zip wcs nwc_tvs)
- ; tcWrapResult (mkHsWrap inst_wrap inner_expr) rho res_ty } }
+ ; tcWrapResult (mkHsWrap inst_wrap inner_expr) rho res_ty }
tcExpr (HsType ty) _
= failWithTc (text "Can't handle type argument:" <+> ppr ty)