Commit fea67bc5 authored by Ian Lynagh's avatar Ian Lynagh
Browse files

Provide a way of 'show'int a Unique without going via SDoc

parent 4b1350ea
......@@ -223,33 +223,26 @@ instance Uniquable Unique where
We do sometimes make strings with @Uniques@ in them:
\begin{code}
pprUnique :: Unique -> SDoc
pprUnique uniq
-- | opt_SuppressUniques
-- = empty -- Used exclusively to suppress uniques so you
-- | otherwise -- can compare output easily
showUnique :: Unique -> String
showUnique uniq
= case unpkUnique uniq of
(tag, u) -> finish_ppr tag u (text (iToBase62 u))
(tag, u) -> finish_show tag u (iToBase62 u)
#ifdef UNUSED
pprUnique10 :: Unique -> SDoc
pprUnique10 uniq -- in base-10, dudes
= case unpkUnique uniq of
(tag, u) -> finish_ppr tag u (int u)
#endif
finish_show :: Char -> Int -> String -> String
finish_show 't' u _pp_u | u < 26
= -- Special case to make v common tyvars, t1, t2, ...
-- come out as a, b, ... (shorter, easier to read)
[chr (ord 'a' + u)]
finish_show tag _ pp_u = tag : pp_u
finish_ppr :: Char -> Int -> SDoc -> SDoc
finish_ppr 't' u _pp_u | u < 26
= -- Special case to make v common tyvars, t1, t2, ...
-- come out as a, b, ... (shorter, easier to read)
char (chr (ord 'a' + u))
finish_ppr tag _ pp_u = char tag <> pp_u
pprUnique :: Unique -> SDoc
pprUnique u = text (showUnique u)
instance Outputable Unique where
ppr u = pprUnique u
ppr = pprUnique
instance Show Unique where
showsPrec p uniq = showsPrecSDoc p (pprUnique uniq)
show uniq = showUnique uniq
\end{code}
%************************************************************************
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment