diff options
author | Sebastian Graf <sebastian.graf@kit.edu> | 2019-10-10 14:44:18 +0200 |
---|---|---|
committer | Sebastian Graf <sgraf1337@gmail.com> | 2019-11-01 13:30:40 +0000 |
commit | db4dbd338cc20c9d167914620423cc35731c15be (patch) | |
tree | eb9829e9a82f108441b6d80e98c2f4f8557361fd /utils/haddock | |
parent | ad1fe274411129f82e7bbfd51bde49775288ae4b (diff) | |
download | haskell-wip/wraploc.tar.gz |
Separate `LPat` from `Pat` on the type-levelwip/wraploc
Since the Trees That Grow effort started, we had `type LPat = Pat`.
This is so that `SrcLoc`s would only be annotated in GHC's AST, which is
the reason why all GHC passes use the extension constructor `XPat` to
attach source locations. See #15495 for the design discussion behind
that.
But now suddenly there are `XPat`s everywhere!
There are several functions which dont't cope with `XPat`s by either
crashing (`hsPatType`) or simply returning incorrect results
(`collectEvVarsPat`).
This issue was raised in #17330. I also came up with a rather clean and
type-safe solution to the problem: We define
```haskell
type family XRec p (f :: * -> *) = r | r -> p f
type instance XRec (GhcPass p) f = Located (f (GhcPass p))
type instance XRec TH f = f p
type LPat p = XRec p Pat
```
This is a rather modular embedding of the old "ping-pong" style, while
we only pay for the `Located` wrapper within GHC. No ping-ponging in
a potential Template Haskell AST, for example. Yet, we miss no case
where we should've handled a `SrcLoc`: `hsPatType` and
`collectEvVarsPat` are not callable at an `LPat`.
Also, this gets rid of one indirection in `Located` variants:
Previously, we'd have to go through `XPat` and `Located` to get from
`LPat` to the wrapped `Pat`. Now it's just `Located` again.
Thus we fix #17330.
Diffstat (limited to 'utils/haddock')
m--------- | utils/haddock | 0 |
1 files changed, 0 insertions, 0 deletions
diff --git a/utils/haddock b/utils/haddock -Subproject fad111e9d3de1a2e86837d3e6f72fe0cf2f6c0a +Subproject b34ca2554a3440f092f585bb7fc1e9d4b2ca861 |