Based on @UniqFMs@ (as you would expect).
-Basically, the things need to be in class @NamedThing@.
+Basically, the things need to be in class @Uniquable@.
\begin{code}
#include "HsVersions.h"
module UniqSet (
- UniqSet(..), -- abstract type: NOT
+ SYN_IE(UniqSet), -- abstract type: NOT
mkUniqSet, uniqSetToList, emptyUniqSet, unitUniqSet,
addOneToUniqSet,
isEmptyUniqSet
) where
-CHK_Ubiq() -- debugging consistency check
+IMP_Ubiq(){-uitous-}
-import Maybes ( maybeToBool, Maybe )
+import Maybes ( maybeToBool )
import UniqFM
import Unique ( Unique )
-import Outputable ( Outputable(..), NamedThing(..), ExportFlag )
import SrcLoc ( SrcLoc )
-import Pretty ( Pretty(..), PrettyRep )
+import Pretty ( SYN_IE(Pretty), PrettyRep )
import PprStyle ( PprStyle )
import Util ( Ord3(..) )
+import {-hide from mkdependHS-}
+ RnHsSyn ( RnName ) -- specialising only
+
#if ! OMIT_NATIVE_CODEGEN
#define IF_NCG(a) a
#else
%* *
%************************************************************************
-We use @UniqFM@, with a (@getItsUnique@-able) @Unique@ as ``key''
+We use @UniqFM@, with a (@uniqueOf@-able) @Unique@ as ``key''
and the thing itself as the ``value'' (for later retrieval).
\begin{code}
emptyUniqSet :: UniqSet a
emptyUniqSet = MkUniqSet emptyUFM
-unitUniqSet :: NamedThing a => a -> UniqSet a
+unitUniqSet :: Uniquable a => a -> UniqSet a
unitUniqSet x = MkUniqSet (unitUFM x x)
uniqSetToList :: UniqSet a -> [a]
uniqSetToList (MkUniqSet set) = eltsUFM set
-mkUniqSet :: NamedThing a => [a] -> UniqSet a
+mkUniqSet :: Uniquable a => [a] -> UniqSet a
mkUniqSet xs = MkUniqSet (listToUFM [ (x, x) | x <- xs])
-addOneToUniqSet :: NamedThing a => UniqSet a -> a -> UniqSet a
+addOneToUniqSet :: Uniquable a => UniqSet a -> a -> UniqSet a
addOneToUniqSet set x = set `unionUniqSets` unitUniqSet x
unionUniqSets :: UniqSet a -> UniqSet a -> UniqSet a
intersectUniqSets :: UniqSet a -> UniqSet a -> UniqSet a
intersectUniqSets (MkUniqSet set1) (MkUniqSet set2) = MkUniqSet (intersectUFM set1 set2)
-elementOfUniqSet :: NamedThing a => a -> UniqSet a -> Bool
+elementOfUniqSet :: Uniquable a => a -> UniqSet a -> Bool
elementOfUniqSet x (MkUniqSet set) = maybeToBool (lookupUFM set x)
isEmptyUniqSet :: UniqSet a -> Bool
isEmptyUniqSet (MkUniqSet set) = isNullUFM set {-SLOW: sizeUFM set == 0-}
-mapUniqSet :: NamedThing b => (a -> b) -> UniqSet a -> UniqSet b
+mapUniqSet :: Uniquable b => (a -> b) -> UniqSet a -> UniqSet b
mapUniqSet f (MkUniqSet set)
= MkUniqSet (listToUFM [ let
mapped_thing = f thing
| thing <- eltsUFM set ])
\end{code}
-%************************************************************************
-%* *
-\subsection{The @IdSet@ and @TyVarSet@ specialisations for sets of Ids/TyVars}
-%* *
-%************************************************************************
-
-@IdSet@ is a specialised version, optimised for sets of Ids.
-
\begin{code}
---type NameSet = UniqSet Name
---type GenTyVarSet flexi = UniqSet (GenTyVar flexi)
---type GenIdSet ty = UniqSet (GenId ty)
-
-#if ! OMIT_NATIVE_CODEGEN
---type RegSet = UniqSet Reg
-#endif
-
-#if 0
#if __GLASGOW_HASKELL__
{-# SPECIALIZE
- unitUniqSet :: GenId ty -> GenIdSet ty,
- GenTyVar flexi -> GenTyVarSet flexi,
- Name -> NameSet
- IF_NCG(COMMA Reg -> RegSet)
+ addOneToUniqSet :: UniqSet Unique -> Unique -> UniqSet Unique
#-}
-
{-# SPECIALIZE
- mkUniqSet :: [GenId ty] -> GenIdSet ty,
- [GenTyVar flexi] -> GenTyVarSet flexi,
- [Name] -> NameSet
- IF_NCG(COMMA [Reg] -> RegSet)
+ elementOfUniqSet :: RnName -> UniqSet RnName -> Bool
+ , Unique -> UniqSet Unique -> Bool
#-}
-
{-# SPECIALIZE
- elementOfUniqSet :: GenId ty -> GenIdSet ty -> Bool,
- GenTyVar flexi -> GenTyVarSet flexi -> Bool,
- Name -> NameSet -> Bool
- IF_NCG(COMMA Reg -> RegSet -> Bool)
+ mkUniqSet :: [RnName] -> UniqSet RnName
#-}
{-# SPECIALIZE
- mapUniqSet :: (GenId ty -> GenId ty) -> GenIdSet ty -> GenIdSet ty,
- (GenTyVar flexi -> GenTyVar flexi) -> GenTyVarSet flexi -> GenTyVarSet flexi,
- (Name -> Name) -> NameSet -> NameSet
- IF_NCG(COMMA (Reg -> Reg) -> RegSet -> RegSet)
+ unitUniqSet :: RnName -> UniqSet RnName
+ , Unique -> UniqSet Unique
#-}
#endif
-#endif
\end{code}