Tidy up Do Expansion implimentation/Kill `GHC.Types.Basic.Origin`
This ticket tracks various tidying up tasks for HsExpansion
Here are some ideas:
- Get rid
Origin
to beautify and stream line theGenerated
code vsFromSource
Code meta-data. See discussion here: !10140 (comment 535779)
The current design depends on GHC.Types.Basic.Origin
and also GHC.Types.SrcLoc.GenLocated
to figure out whether a source code's origin is user written or not.
The objective is that we should only be using one thing to identify the source codes origin. The current tcExpr
already uses GHC.Types.SrcLoc.GenLocated
to identify the src origin using isGeneratedCode :: TcRn Bool
and we would be able to reuse that functionality rather than depending on GHC.Types.Basic.Origin
.
- Kill
GenReason
inGHC.Types.Basic.Origin
and clean up smelly code like this one in GHC.HstoCore.Match.matchWrapper
= do { dflags <- getDynFlags
; locn <- getSrcSpanDs
; let matches
= if any (is_pat_syn_match origin) matches'
then filter (non_gen_wc origin) matches'
-- filter out the wild pattern fail alternatives
-- which have a do expansion origin
-- They generate spurious overlapping warnings
-- Due to pattern synonyms treated as refutable patterns
-- See Part 1's Wrinkle 1 in Note [Expanding HsDo with XXExprGhcRn] in GHC.Tc.Gen.Do
Edited by Apoorv Ingle