summaryrefslogtreecommitdiff
path: root/compiler/GHC/Core.hs
diff options
context:
space:
mode:
authorSebastian Graf <sebastian.graf@kit.edu>2021-03-09 21:58:31 +0100
committerSebastian Graf <sebastian.graf@kit.edu>2021-03-10 13:13:43 +0100
commiteed207c6541fd37e405e81a82d9b431a84410667 (patch)
treea1ae3b6df0329d578b73761007d4cbbfd5b125f4 /compiler/GHC/Core.hs
parent7a728ca6a52ff8c1a1ad43c81cf9289a61dca107 (diff)
downloadhaskell-wip/T19516.tar.gz
Core lint: Lint top-level non-rec bindings with correct RecFlag (#19516)wip/T19516
This patch arranges it so that top-level bindings are linted group-by-group and with their correct `RecFlag`. Before, CoreLint treated all top-level bindings as one big recursive group. Fixes #19516.
Diffstat (limited to 'compiler/GHC/Core.hs')
-rw-r--r--compiler/GHC/Core.hs7
1 files changed, 6 insertions, 1 deletions
diff --git a/compiler/GHC/Core.hs b/compiler/GHC/Core.hs
index 168e33e189..46ecd8bed3 100644
--- a/compiler/GHC/Core.hs
+++ b/compiler/GHC/Core.hs
@@ -41,7 +41,7 @@ module GHC.Core (
isId, cmpAltCon, cmpAlt, ltAlt,
-- ** Simple 'Expr' access functions and predicates
- bindersOf, bindersOfBinds, rhssOfBind, rhssOfAlts,
+ decomposeBind, bindersOf, bindersOfBinds, rhssOfBind, rhssOfAlts,
collectBinders, collectTyBinders, collectTyAndValBinders,
collectNBinders,
collectArgs, stripNArgs, collectArgsTicks, flattenBinds,
@@ -2123,6 +2123,11 @@ exprToCoercion_maybe _ = Nothing
************************************************************************
-}
+-- | Turn a binding group into a 'RecFlag' and a list of bindings.
+decomposeBind :: Bind b -> (RecFlag, [(b, Expr b)])
+decomposeBind (NonRec bndr rhs) = (NonRecursive, [(bndr, rhs)])
+decomposeBind (Rec pairs) = (Recursive, pairs)
+
-- | Extract every variable by this group
bindersOf :: Bind b -> [b]
-- If you edit this function, you may need to update the GHC formalism