summaryrefslogtreecommitdiff
path: root/utils/check-exact
diff options
context:
space:
mode:
authorArtyom Kuznetsov <hi@wzrd.ht>2021-07-29 12:10:29 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-08-10 15:00:42 -0400
commit130f94dbd3536bd409621cbaac4659ababf613b3 (patch)
tree55809a2f6f91bfecadcc6a1ef7d4f3895cc6c253 /utils/check-exact
parent741fdf0e4f371afbd8ef36f81bbb90a2049b005c (diff)
downloadhaskell-130f94dbd3536bd409621cbaac4659ababf613b3.tar.gz
Refactor HsStmtContext and remove HsDoRn
Parts of HsStmtContext were split into a separate data structure HsDoFlavour. Before this change HsDo used to have HsStmtContext inside, but in reality only parts of HsStmtContext were used and other cases were invariants handled with panics. Separating those parts into its own data structure helps us to get rid of those panics as well as HsDoRn type family.
Diffstat (limited to 'utils/check-exact')
-rw-r--r--utils/check-exact/ExactPrint.hs4
-rw-r--r--utils/check-exact/Utils.hs15
2 files changed, 3 insertions, 16 deletions
diff --git a/utils/check-exact/ExactPrint.hs b/utils/check-exact/ExactPrint.hs
index e4f689bbbb..74135cb9f6 100644
--- a/utils/check-exact/ExactPrint.hs
+++ b/utils/check-exact/ExactPrint.hs
@@ -2080,14 +2080,12 @@ instance ExactPrint (HsExpr GhcPs) where
-- ---------------------------------------------------------------------
exactDo :: (ExactPrint body)
- => EpAnn AnnList -> (HsStmtContext any) -> body -> EPP ()
+ => EpAnn AnnList -> HsDoFlavour -> body -> EPP ()
exactDo an (DoExpr m) stmts = exactMdo an m AnnDo >> markAnnotatedWithLayout stmts
exactDo an GhciStmtCtxt stmts = markLocatedAAL an al_rest AnnDo >> markAnnotatedWithLayout stmts
-exactDo an ArrowExpr stmts = markLocatedAAL an al_rest AnnDo >> markAnnotatedWithLayout stmts
exactDo an (MDoExpr m) stmts = exactMdo an m AnnMdo >> markAnnotatedWithLayout stmts
exactDo _ ListComp stmts = markAnnotatedWithLayout stmts
exactDo _ MonadComp stmts = markAnnotatedWithLayout stmts
-exactDo _ _ _ = panic "pprDo" -- PatGuard, ParStmtCxt
exactMdo :: EpAnn AnnList -> Maybe ModuleName -> AnnKeywordId -> EPP ()
exactMdo an Nothing kw = markLocatedAAL an al_rest kw
diff --git a/utils/check-exact/Utils.hs b/utils/check-exact/Utils.hs
index 5739df9dd3..74a861e773 100644
--- a/utils/check-exact/Utils.hs
+++ b/utils/check-exact/Utils.hs
@@ -207,19 +207,8 @@ orderByKey keys order
-- ---------------------------------------------------------------------
-isListComp :: HsStmtContext name -> Bool
-isListComp cts = case cts of
- ListComp -> True
- MonadComp -> True
-
- DoExpr {} -> False
- MDoExpr {} -> False
- ArrowExpr -> False
- GhciStmtCtxt -> False
-
- PatGuard {} -> False
- ParStmtCtxt {} -> False
- TransStmtCtxt {} -> False
+isListComp :: HsDoFlavour -> Bool
+isListComp = isDoComprehensionContext
-- ---------------------------------------------------------------------