summaryrefslogtreecommitdiff
path: root/compiler/GHC/HsToCore/Match
diff options
context:
space:
mode:
authorJohn Ericson <git@JohnEricson.me>2020-01-25 15:46:07 -0500
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-04-23 18:32:43 -0400
commitc42754d5fdd3c2db554d9541bab22d1b3def4be7 (patch)
treeeea28083a89e73b8e08a0d2387eaff19ecf05f13 /compiler/GHC/HsToCore/Match
parent5946c85abcf66555cdbcd3eed02cb8f512b6110c (diff)
downloadhaskell-c42754d5fdd3c2db554d9541bab22d1b3def4be7.tar.gz
Trees That Grow refactor for `ConPat` and `CoPat`
- `ConPat{In,Out}` -> `ConPat` - `CoPat` -> `XPat (CoPat ..)` Note that `GHC.HS.*` still uses `HsWrap`, but only when `p ~ GhcTc`. After this change, moving the type family instances out of `GHC.HS.*` is sufficient to break the cycle. Add XCollectPat class to decide how binders are collected from XXPat based on the pass. Previously we did this with IsPass, but that doesn't work for Haddock's DocNameI, and the constraint doesn't express what actual distinction is being made. Perhaps a class for collecting binders more generally is in order, but we haven't attempted this yet. Pure refactor of code around ConPat - InPat/OutPat synonyms removed - rename several identifiers - redundant constraints removed - move extension field in ConPat to be first - make ConPat use record syntax more consistently Fix T6145 (ConPatIn became ConPat) Add comments from SPJ. Add comment about haddock's use of CollectPass. Updates haddock submodule.
Diffstat (limited to 'compiler/GHC/HsToCore/Match')
-rw-r--r--compiler/GHC/HsToCore/Match/Constructor.hs26
1 files changed, 19 insertions, 7 deletions
diff --git a/compiler/GHC/HsToCore/Match/Constructor.hs b/compiler/GHC/HsToCore/Match/Constructor.hs
index f9c3e021d4..c7022d6b1d 100644
--- a/compiler/GHC/HsToCore/Match/Constructor.hs
+++ b/compiler/GHC/HsToCore/Match/Constructor.hs
@@ -145,9 +145,16 @@ matchOneConLike vars ty (eqn1 :| eqns) -- All eqns for a single constructor
; return $ foldr1 (.) wraps <$> match_result
}
- shift (_, eqn@(EqnInfo { eqn_pats = ConPatOut{ pat_tvs = tvs, pat_dicts = ds,
- pat_binds = bind, pat_args = args
- } : pats }))
+ shift (_, eqn@(EqnInfo
+ { eqn_pats = ConPat
+ { pat_args = args
+ , pat_con_ext = ConPatTc
+ { cpt_tvs = tvs
+ , cpt_dicts = ds
+ , cpt_binds = bind
+ }
+ } : pats
+ }))
= do ds_bind <- dsTcEvBinds bind
return ( wrapBinds (tvs `zip` tvs1)
. wrapBinds (ds `zip` dicts1)
@@ -173,10 +180,15 @@ matchOneConLike vars ty (eqn1 :| eqns) -- All eqns for a single constructor
alt_wrapper = wrapper1,
alt_result = foldr1 combineMatchResults match_results } }
where
- ConPatOut { pat_con = L _ con1
- , pat_arg_tys = arg_tys, pat_wrap = wrapper1,
- pat_tvs = tvs1, pat_dicts = dicts1, pat_args = args1 }
- = firstPat eqn1
+ ConPat { pat_con = L _ con1
+ , pat_args = args1
+ , pat_con_ext = ConPatTc
+ { cpt_arg_tys = arg_tys
+ , cpt_wrap = wrapper1
+ , cpt_tvs = tvs1
+ , cpt_dicts = dicts1
+ }
+ } = firstPat eqn1
fields1 = map flSelector (conLikeFieldLabels con1)
ex_tvs = conLikeExTyCoVars con1