On Friday 05 November 2004 15:07, Benjamin Franksen wrote: > instance Typeable a => Typeable (MVar a) where > typeOf x = > mkAppTy (mkTyCon "Control.Concurrent.MVar.MVar") [typeOf y] > where > y = unsafePerformIO $ do > z <- newEmptyMVar >>= readMVar > return (z `asTypeOf` x)
which is wrong because it also passes the typeOf of the MVar and not the content. This one is correct, I hope: instance Typeable a => Typeable (MVar a) where typeOf x = mkAppTy (mkTyCon "Control.Concurrent.MVar.MVar") [typeOf v] where v = unsafePerformIO $ do y <- newEmptyMVar readMVar (y `asTypeOf` x) On Friday 05 November 2004 16:44, Koji Nakahara wrote: > instance Typeable a => Typeable (MVar a) where > typeOf (x :: MVar a) = > mkAppTy (mkTyCon "Control.Concurrent.MVar.MVar") [typeOf (undefined::a)] Yes, that's it. The above is a lot more convoluted but has a small advantage: it doesn't need -fglasgow-exts. I understand now, why pattern signatures were deemed a useful feature! Thanks to all who helped. Cheers, Ben _______________________________________________ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe