Skip to content

Break dependency from HsSyn on the typechecker.

Commit message:

Break dependency from HsSyn on the typechecker.

There are three reasons that HsSyn has depended
on the type-checker.

1. The AST contains HsWrappers in a variety of places -- notably,
   in expressions. HsWrappers are part of type-checker evidence,
   and they are declared in TcEvidence.

2. In a few places (notably, AbsBinds), the AST contains a TcEvBinds.
   TcEvBinds is also declared in TcEvidence.

3. Expressions can contain *delayed splices*. See Note [Running typed
   splices in the zonker] in Hs.Expr. A DelayedSplice structure needs
   a reference to a TcLclEnv, declared in TcRnTypes and rather
   intimately tied to the type-checker.

The third of these is the most pernicious, because it requires
a dependency on a central module within the type-checker. TcEvidence,
on the other hand, might conceivably be moved out from the type-checker.

This patch removes all three dependencies. The magic is all
in Note [Abstract data] in Hs.Extension. In order to support this
change, this patch also introduces some new constraints in Hs.Extension.
Specifically, we now have IsGhcPass, which allows functions to
do a runtiem (of GHC) check to see what phase we're in, in order
to do custom processing in one phase or another.

Somewhat separately, this patch also moves HsWrap and HsCmdWrap
into an extension field. CoPat should get the same treatment, but
is not included in this patch. And, of course, there are many other
places that constructors should be moved to extension fields (like
ConPatOut). This change is actually orthogonal to the
dependency-dropping, but it seemed convenient to do them all together.

This patch subsumes !1721 (sorry @chreekat).

NB: This is based on !1875 (closed), but I'm hoping that the MR display shows only what's new in this patch.

Merge request reports