Fwd: [Haskell-cafe] Auto-deriving Control.Exception.Exception
Antoine Latter
aslatter at gmail.com
Sun Jan 4 15:13:50 EST 2009
Forwarding response to cafe
---------- Forwarded message ----------
From: Antoine Latter <aslatter at gmail.com>
Date: Sun, Jan 4, 2009 at 2:13 PM
Subject: Re: [Haskell-cafe] Auto-deriving Control.Exception.Exception
To: "eyal.lotem at gmail.com" <eyal.lotem at gmail.com>
On Sun, Jan 4, 2009 at 11:50 AM, eyal.lotem at gmail.com
<eyal.lotem at gmail.com> wrote:
> 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
More information about the Haskell-Cafe
mailing list