summaryrefslogtreecommitdiff
path: root/compiler/GHC/Core/Subst.hs
diff options
context:
space:
mode:
authorKrzysztof Gogolewski <krzysztof.gogolewski@tweag.io>2023-02-04 09:39:16 +0100
committerKrzysztof Gogolewski <krzysztof.gogolewski@tweag.io>2023-04-17 19:36:48 +0200
commit1eb400b06fc3dfa6f09447f5962b9dee34e2da97 (patch)
treed83bc0c10537059aca711d6cf3dd7ecd42d6cfef /compiler/GHC/Core/Subst.hs
parenta1371ebb53a8206d6d99ac0d9bff4ed8a3043498 (diff)
downloadhaskell-wip/misc-cleanup6.tar.gz
Misc cleanupwip/misc-cleanup6
- Use dedicated list functions - Make cloneBndrs and cloneRecIdBndrs monadic - Fix invalid haddock comments in libraries/base
Diffstat (limited to 'compiler/GHC/Core/Subst.hs')
-rw-r--r--compiler/GHC/Core/Subst.hs18
1 files changed, 9 insertions, 9 deletions
diff --git a/compiler/GHC/Core/Subst.hs b/compiler/GHC/Core/Subst.hs
index f0ad737fb6..e6fd91dc0a 100644
--- a/compiler/GHC/Core/Subst.hs
+++ b/compiler/GHC/Core/Subst.hs
@@ -417,11 +417,12 @@ cloneIdBndrs :: Subst -> UniqSupply -> [Id] -> (Subst, [Id])
cloneIdBndrs subst us ids
= mapAccumL (clone_id subst) subst (ids `zip` uniqsFromSupply us)
-cloneBndrs :: Subst -> UniqSupply -> [Var] -> (Subst, [Var])
+cloneBndrs :: MonadUnique m => Subst -> [Var] -> m (Subst, [Var])
-- Works for all kinds of variables (typically case binders)
-- not just Ids
-cloneBndrs subst us vs
- = mapAccumL (\subst (v, u) -> cloneBndr subst u v) subst (vs `zip` uniqsFromSupply us)
+cloneBndrs subst vs
+ = do us <- getUniquesM
+ pure $ mapAccumL (\subst (v, u) -> cloneBndr subst u v) subst (vs `zip` us)
cloneBndr :: Subst -> Unique -> Var -> (Subst, Var)
cloneBndr subst uniq v
@@ -429,12 +430,11 @@ cloneBndr subst uniq v
| otherwise = clone_id subst subst (v,uniq) -- Works for coercion variables too
-- | Clone a mutually recursive group of 'Id's
-cloneRecIdBndrs :: Subst -> UniqSupply -> [Id] -> (Subst, [Id])
-cloneRecIdBndrs subst us ids
- = (subst', ids')
- where
- (subst', ids') = mapAccumL (clone_id subst') subst
- (ids `zip` uniqsFromSupply us)
+cloneRecIdBndrs :: MonadUnique m => Subst -> [Id] -> m (Subst, [Id])
+cloneRecIdBndrs subst ids
+ = do us <- getUniquesM
+ let (subst', ids') = mapAccumL (clone_id subst') subst (ids `zip` us)
+ pure (subst', ids')
-- Just like substIdBndr, except that it always makes a new unique
-- It is given the unique to use