Fwd: [Haskell-cafe] Auto-deriving Control.Exception.Exception

Forwarding response to cafe
---------- Forwarded message ----------
From: Antoine Latter
If this is valid:
import qualified Control.Exception as Exc
genericFromException :: Typeable a => Exc.SomeException -> Maybe a genericFromException (Exc.SomeException e) = cast e instance Exc.Exception SomeType where fromException = genericFromException
then why not have an auto-deriving rule for Exception (fromException = cast . unSomeException)?
If you just say:
instance Exception YourType where
and leave the instance body empty, it will use the default definitions of 'fromException' and 'toException', which do the right thing by default. At least, I'm pretty sure that's what happens. The Haddock docs have lost their links to the source code. -Antoine
participants (1)
-
Antoine Latter