\begin{code}
module Unique (
- Unique, Uniquable(..), hasKey,
+ -- * Main data types
+ Unique, Uniquable(..),
+
+ -- ** Constructors, desctructors and operations on 'Unique's
+ hasKey,
pprUnique,
isTupleKey,
+ -- ** Making built-in uniques
+
-- now all the built-in Uniques (and functions to make them)
-- [the Oh-So-Wonderful Haskell module system wins again...]
mkAlphaTyVarUnique,
import FastString
import Outputable
import StaticFlags
-import Util
#if defined(__GLASGOW_HASKELL__)
--just for implementing a fast [0,61) -> Char function
\begin{code}
--why not newtype Int?
+
+-- | The type of unique identifiers that are used in many places in GHC
+-- for fast ordering and equality tests. You should generate these with
+-- the functions from the 'UniqSupply' module
data Unique = MkUnique FastInt
\end{code}
%************************************************************************
\begin{code}
+-- | Class of things that we can obtain a 'Unique' from
class Uniquable a where
getUnique :: a -> Unique
\begin{code}
pprUnique :: Unique -> SDoc
pprUnique uniq
- | debugIsOn && opt_SuppressUniques
+ | opt_SuppressUniques
= empty -- Used exclusively to suppress uniques so you
| otherwise -- can compare output easily
= case unpkUnique uniq of
X: uniques derived by deriveUnique
_: unifiable tyvars (above)
0-9: prelude things below
+ (no numbers left any more..)
+ :: (prelude) parallel array data constructors
other a-z: lower case chars for unique supplies. Used so far:
isTupleKey u = case unpkUnique u of
(tag,_) -> tag == '4' || tag == '5' || tag == '7' || tag == '8'
-mkPrimOpIdUnique op = mkUnique '9' op
-mkPreludeMiscIdUnique i = mkUnique '0' i
+mkPrimOpIdUnique op = mkUnique '9' op
+mkPreludeMiscIdUnique i = mkUnique '0' i
-- No numbers left anymore, so I pick something different for the character
-- tag