[Haskell-cafe] how to catch keyboard interrupts?

Ryan Ingram ryani.spam at gmail.com
Sun Feb 24 13:32:09 EST 2008


This is pretty cool, but I have one warning:

On Sat, Feb 23, 2008 at 4:37 PM, Uwe Hollerbach <uhollerbach at gmail.com> wrote:
>  > data MyInterrupt = MyInt Int
>  > instance Typeable MyInterrupt where
>  >   typeOf x = typeOf (0 :: Int)

I am pretty sure that this makes Dynamic unsound; you could
accidentally cast from an Int to a MyInterrupt or vice versa.  Try
this instead:

> data MyException = Interrupt deriving Typeable

then you can safely use throwDyn and catchDyn on this type.

   -- ryan


More information about the Haskell-Cafe mailing list