projects
/
ghc-hetmet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add the notion of "constructor-like" Ids for rule-matching
[ghc-hetmet.git]
/
compiler
/
basicTypes
/
Unique.lhs
diff --git
a/compiler/basicTypes/Unique.lhs
b/compiler/basicTypes/Unique.lhs
index
36a5352
..
202ae9e
100644
(file)
--- a/
compiler/basicTypes/Unique.lhs
+++ b/
compiler/basicTypes/Unique.lhs
@@
-17,7
+17,11
@@
Haskell).
\begin{code}
module Unique (
\begin{code}
module Unique (
- Unique, Uniquable(..), hasKey,
+ -- * Main data types
+ Unique, Uniquable(..),
+
+ -- ** Constructors, desctructors and operations on 'Unique's
+ hasKey,
pprUnique,
pprUnique,
@@
-32,6
+36,8
@@
module Unique (
isTupleKey,
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,
-- now all the built-in Uniques (and functions to make them)
-- [the Oh-So-Wonderful Haskell module system wins again...]
mkAlphaTyVarUnique,
@@
-54,6
+60,7
@@
import BasicTypes
import FastTypes
import FastString
import Outputable
import FastTypes
import FastString
import Outputable
+import StaticFlags
#if defined(__GLASGOW_HASKELL__)
--just for implementing a fast [0,61) -> Char function
#if defined(__GLASGOW_HASKELL__)
--just for implementing a fast [0,61) -> Char function
@@
-75,6
+82,10
@@
Fast comparison is everything on @Uniques@:
\begin{code}
--why not newtype Int?
\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}
data Unique = MkUnique FastInt
\end{code}
@@
-145,6
+156,7
@@
unpkUnique (MkUnique u)
%************************************************************************
\begin{code}
%************************************************************************
\begin{code}
+-- | Class of things that we can obtain a 'Unique' from
class Uniquable a where
getUnique :: a -> Unique
class Uniquable a where
getUnique :: a -> Unique
@@
-199,11
+211,9
@@
We do sometimes make strings with @Uniques@ in them:
\begin{code}
pprUnique :: Unique -> SDoc
pprUnique uniq
\begin{code}
pprUnique :: Unique -> SDoc
pprUnique uniq
-#ifdef DEBUG
| opt_SuppressUniques
= empty -- Used exclusively to suppress uniques so you
| otherwise -- can compare output easily
| opt_SuppressUniques
= empty -- Used exclusively to suppress uniques so you
| otherwise -- can compare output easily
-#endif
= case unpkUnique uniq of
(tag, u) -> finish_ppr tag u (text (iToBase62 u))
= case unpkUnique uniq of
(tag, u) -> finish_ppr tag u (text (iToBase62 u))
@@
-277,13
+287,14
@@
Allocation of unique supply characters:
X: uniques derived by deriveUnique
_: unifiable tyvars (above)
0-9: prelude things below
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:
d desugarer
f AbsC flattener
g SimplStg
other a-z: lower case chars for unique supplies. Used so far:
d desugarer
f AbsC flattener
g SimplStg
- l ndpFlatten
n Native codegen
r Hsc name cache
s simplifier
n Native codegen
r Hsc name cache
s simplifier
@@
-326,8
+337,8
@@
mkTupleDataConUnique Unboxed a = mkUnique '8' (2*a)
isTupleKey u = case unpkUnique u of
(tag,_) -> tag == '4' || tag == '5' || tag == '7' || tag == '8'
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
-- No numbers left anymore, so I pick something different for the character
-- tag