Repository : ssh://darcs.haskell.org//srv/darcs/ghc On branch : master
http://hackage.haskell.org/trac/ghc/changeset/fea67bc512433dfb042d262a3d86170190a2ddb1 >--------------------------------------------------------------- commit fea67bc512433dfb042d262a3d86170190a2ddb1 Author: Ian Lynagh <[email protected]> Date: Tue Jun 12 12:05:38 2012 +0100 Provide a way of 'show'int a Unique without going via SDoc >--------------------------------------------------------------- compiler/basicTypes/Unique.lhs | 33 +++++++++++++-------------------- 1 files changed, 13 insertions(+), 20 deletions(-) diff --git a/compiler/basicTypes/Unique.lhs b/compiler/basicTypes/Unique.lhs index 7c0f26f..39b30d9 100644 --- a/compiler/basicTypes/Unique.lhs +++ b/compiler/basicTypes/Unique.lhs @@ -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} %************************************************************************ _______________________________________________ Cvs-ghc mailing list [email protected] http://www.haskell.org/mailman/listinfo/cvs-ghc
