diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2021-05-04 20:09:31 -0400 |
---|---|---|
committer | Ryan Scott <ryan.gl.scott@gmail.com> | 2022-04-02 07:11:30 -0400 |
commit | ff8d81265090dc89e067a08028d9c598f72529ab (patch) | |
tree | 1e3393647bd970d9fa515529cadcce35aceff16b /utils | |
parent | d85c7dcb7c457efc23b20ac8f4e4ae88bae5b050 (diff) | |
download | haskell-wip/T18389-task-zero.tar.gz |
Introduce and use ConGadtSigBody (preparatory refactor for #18389)wip/T18389-task-zero
This patch removes the `con_g_args :: HsConDeclGADTDetails pass` and
`con_res_ty :: LHsType pass` fields of `ConDeclGADT` in favor of a unified
`con_body :: ConGadtSigBody pass` field. There are two major differences
between `HsConDeclGADTDetails` and `ConGadtSigBody`:
1. `HsConDeclGADTDetails` only contains the argument type, while
`ConGadtSigBody` contains both the argument and result types.
2. The `PrefixConGADT` constructor of `ConGadtSigBody` now uses a new
`PrefixConGadtSigBody` data type. `PrefixConGadtSigBody` closely mirrors the
structure of `HsType`, but with minor, data constructor–specific tweaks.
This will become vital in a future patch which implements nested `forall`s
and contexts in prefix GADT constructor types (see #18389).
Besides the refactoring in the GHC API (and some minor changes in
GHC AST–related test cases) this does not introduce any user-visible
changes in behavior.
Diffstat (limited to 'utils')
-rw-r--r-- | utils/check-exact/ExactPrint.hs | 19 | ||||
m--------- | utils/haddock | 0 |
2 files changed, 13 insertions, 6 deletions
diff --git a/utils/check-exact/ExactPrint.hs b/utils/check-exact/ExactPrint.hs index 3d493cfd22..0e81894017 100644 --- a/utils/check-exact/ExactPrint.hs +++ b/utils/check-exact/ExactPrint.hs @@ -3224,8 +3224,8 @@ instance ExactPrint (ConDecl GhcPs) where exact (ConDeclGADT { con_g_ext = an , con_names = cons , con_bndrs = bndrs - , con_mb_cxt = mcxt, con_g_args = args - , con_res_ty = res_ty, con_doc = doc }) = do + , con_mb_cxt = mcxt + , con_body = body, con_doc = doc }) = do mapM_ markAnnotated doc mapM_ markAnnotated cons markEpAnn an AnnDcolon @@ -3237,13 +3237,14 @@ instance ExactPrint (ConDecl GhcPs) where mapM_ markAnnotated mcxt when (isJust mcxt) $ markEpAnn an AnnDarrow -- mapM_ markAnnotated args - case args of - PrefixConGADT args' -> mapM_ markAnnotated args' - RecConGADT fields arr -> do + case body of + PrefixConGADT body' -> + exact_prefix_con_gadt_sig_body body' + RecConGADT fields arr res_ty -> do markAnnotated fields markUniToken arr + markAnnotated res_ty -- mapM_ markAnnotated (unLoc fields) - markAnnotated res_ty -- markAST _ (GHC.ConDeclGADT _ lns (GHC.L l forall) qvars mbCxt args typ _) = do -- setContext (Set.singleton PrefixOp) $ markListIntercalate lns -- mark GHC.AnnDcolon @@ -3254,6 +3255,12 @@ instance ExactPrint (ConDecl GhcPs) where -- markLocated typ -- markManyOptional GHC.AnnCloseP -- markTrailingSemi + where + exact_prefix_con_gadt_sig_body (PCGSRes res_ty) = + markAnnotated res_ty + exact_prefix_con_gadt_sig_body (PCGSAnonArg arg_ty body') = do + markAnnotated arg_ty + exact_prefix_con_gadt_sig_body body' -- pprConDecl (ConDeclGADT { con_names = cons, con_qvars = qvars -- , con_mb_cxt = mcxt, con_args = args diff --git a/utils/haddock b/utils/haddock -Subproject 58237d76c96325f25627bfd7cdad5b93364d29a +Subproject d1aa841631b018c00b65e7a129c7e103cc8df6a |