@@ -25,6 +25,8 @@ import qualified Data.HashMap.Strict as Map
2525import Data.HashSet (HashSet , member )
2626import qualified Data.IntMap as IM
2727import qualified Data.HashSet as Set
28+ import qualified Data.Text as T
29+ import Data.Text (Text )
2830import Data.IORef
2931import Data.List (intercalate )
3032import Data.Maybe
@@ -86,11 +88,11 @@ newtype Step = Step Int
8688---------------------------------------------------------------------
8789-- Keys
8890
89- data KeyValue = forall a . (Typeable a , Hashable a , Show a ) => KeyValue a
91+ data KeyValue = forall a . (Typeable a , Hashable a , Show a ) => KeyValue a Text
9092
9193newtype Key = UnsafeMkKey Int
9294
93- pattern Key a <- (lookupKeyValue -> KeyValue a)
95+ pattern Key a <- (lookupKeyValue -> KeyValue a _ )
9496
9597data KeyMap = KeyMap ! (Map. HashMap KeyValue Key ) ! (IM. IntMap KeyValue ) {- # UNPACK #-} !Int
9698
@@ -101,7 +103,7 @@ keyMap = unsafePerformIO $ newIORef (KeyMap Map.empty IM.empty 0)
101103
102104newKey :: (Typeable a , Hashable a , Show a ) => a -> Key
103105newKey k = unsafePerformIO $ do
104- let ! newKey = KeyValue k
106+ let ! newKey = KeyValue k ( T. pack ( show k))
105107 atomicModifyIORef' keyMap $ \ km@ (KeyMap hm im n) ->
106108 let new_key = Map. lookup newKey hm
107109 in case new_key of
@@ -126,11 +128,14 @@ instance Show Key where
126128 show (Key x) = show x
127129
128130instance Eq KeyValue where
129- KeyValue a == KeyValue b = Just a == cast b
131+ KeyValue a _ == KeyValue b _ = Just a == cast b
130132instance Hashable KeyValue where
131- hashWithSalt i (KeyValue x) = hashWithSalt i (typeOf x, x)
133+ hashWithSalt i (KeyValue x _ ) = hashWithSalt i (typeOf x, x)
132134instance Show KeyValue where
133- show (KeyValue x) = show x
135+ show (KeyValue x t) = T. unpack t
136+
137+ renderKey :: Key -> Text
138+ renderKey (lookupKeyValue -> KeyValue _ t) = t
134139
135140newtype Value = Value Dynamic
136141
0 commit comments