summaryrefslogtreecommitdiff
path: root/compiler/GHC/Iface/Ext
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2020-09-13 08:58:40 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-09-15 15:21:43 -0400
commit4283feaa9e0826211f7a71d543054c989ea32965 (patch)
tree93f96b0599ed403b0180b0416c13f14a193bb1e4 /compiler/GHC/Iface/Ext
parentb3143f5a0827b640840ef241a30933dc23b69d91 (diff)
downloadhaskell-4283feaa9e0826211f7a71d543054c989ea32965.tar.gz
Introduce and use DerivClauseTys (#18662)
This switches `deriv_clause_tys` so that instead of using a list of `LHsSigType`s to represent the types in a `deriving` clause, it now uses a sum type. `DctSingle` represents a `deriving` clause with no enclosing parentheses, while `DctMulti` represents a clause with enclosing parentheses. This makes pretty-printing easier and avoids confusion between `HsParTy` and the enclosing parentheses in `deriving` clauses, which are different semantically. Fixes #18662.
Diffstat (limited to 'compiler/GHC/Iface/Ext')
-rw-r--r--compiler/GHC/Iface/Ext/Ast.hs10
1 files changed, 7 insertions, 3 deletions
diff --git a/compiler/GHC/Iface/Ext/Ast.hs b/compiler/GHC/Iface/Ext/Ast.hs
index 52a62862ce..b123450b60 100644
--- a/compiler/GHC/Iface/Ext/Ast.hs
+++ b/compiler/GHC/Iface/Ext/Ast.hs
@@ -1507,12 +1507,16 @@ instance ToHie (Located [Located (HsDerivingClause GhcRn)]) where
instance ToHie (Located (HsDerivingClause GhcRn)) where
toHie (L span cl) = concatM $ makeNode cl span : case cl of
- HsDerivingClause _ strat (L ispan tys) ->
+ HsDerivingClause _ strat dct ->
[ toHie strat
- , locOnly ispan
- , toHie $ map (TS (ResolvedScopes [])) tys
+ , toHie dct
]
+instance ToHie (Located (DerivClauseTys GhcRn)) where
+ toHie (L span dct) = concatM $ makeNode dct span : case dct of
+ DctSingle _ ty -> [ toHie $ TS (ResolvedScopes[]) ty ]
+ DctMulti _ tys -> [ toHie $ map (TS (ResolvedScopes [])) tys ]
+
instance ToHie (Located (DerivStrategy GhcRn)) where
toHie (L span strat) = concatM $ makeNode strat span : case strat of
StockStrategy -> []