[Haskell-cafe] The Typeable class is changing

jutaro jnf at arcor.de
Mon Jul 11 22:22:06 CEST 2011


I hope that typeRepKey is no longer in the IO monad (for the simple reason to
teach me that the key can change between session). This forced me to use
unsafePerformIO to make a typeable boxed type of instances of Ord an
instance of Ord (to put it in a Map). Or did I miss something and I can do
better anyhow?

e.g.:
class (Ord s, Typeable s) => Selector s
data GenSelector = forall s . Selector s =>  GS s

instance Ord GenSelector where
    compare (GS a) (GS b) = if typeOf a == typeOf b then
                    compare (fromJust (cast a)) b
                    else compare (unsafePerformIO $ typeRepKey $ typeOf a)
                                 (unsafePerformIO $ typeRepKey $ typeOf b)

Jürgen Nicklisch
 

--
View this message in context: http://haskell.1045720.n5.nabble.com/The-Typeable-class-is-changing-tp4576031p4576350.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.



More information about the Haskell-Cafe mailing list