From 2304c6972fd485de335d1490008fc066055c81c3 Mon Sep 17 00:00:00 2001
From: Ben Gamari <ben@smart-cactus.org>
Date: Mon, 15 May 2023 20:03:39 -0400
Subject: [PATCH] compiler: Make OccSet opaque

---
 compiler/GHC/Types/Name/Occurrence.hs | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/compiler/GHC/Types/Name/Occurrence.hs b/compiler/GHC/Types/Name/Occurrence.hs
index 316b3e911fd8..6a7aea46532d 100644
--- a/compiler/GHC/Types/Name/Occurrence.hs
+++ b/compiler/GHC/Types/Name/Occurrence.hs
@@ -809,7 +809,7 @@ forceOccEnv nf (MkOccEnv fs) = seqEltsUFM (seqEltsUFM nf) fs
 
 --------------------------------------------------------------------------------
 
-type OccSet = FastStringEnv (UniqSet NameSpace)
+newtype OccSet = OccSet (FastStringEnv (UniqSet NameSpace))
 
 emptyOccSet       :: OccSet
 unitOccSet        :: OccName -> OccSet
@@ -821,15 +821,15 @@ unionManyOccSets  :: [OccSet] -> OccSet
 elemOccSet        :: OccName -> OccSet -> Bool
 isEmptyOccSet     :: OccSet -> Bool
 
-emptyOccSet       = emptyFsEnv
-unitOccSet (OccName ns s) = unitFsEnv s (unitUniqSet ns)
+emptyOccSet       = OccSet emptyFsEnv
+unitOccSet (OccName ns s) = OccSet $ unitFsEnv s (unitUniqSet ns)
 mkOccSet          = extendOccSetList emptyOccSet
-extendOccSet      occs (OccName ns s) = extendFsEnv occs s (unitUniqSet ns)
-extendOccSetList  = foldl extendOccSet
-unionOccSets      = plusFsEnv_C unionUniqSets
+extendOccSet      (OccSet occs) (OccName ns s) = OccSet $ extendFsEnv occs s (unitUniqSet ns)
+extendOccSetList  = foldl' extendOccSet
+unionOccSets      (OccSet xs) (OccSet ys) = OccSet $ plusFsEnv_C unionUniqSets xs ys
 unionManyOccSets  = foldl' unionOccSets emptyOccSet
-elemOccSet (OccName ns s) occs = maybe False (elementOfUniqSet ns) $ lookupFsEnv occs s
-isEmptyOccSet     = isNullUFM
+elemOccSet (OccName ns s) (OccSet occs) = maybe False (elementOfUniqSet ns) $ lookupFsEnv occs s
+isEmptyOccSet     (OccSet occs) = isNullUFM occs
 
 {-
 ************************************************************************
-- 
GitLab