> From: Ross Paterson [mailto:[EMAIL PROTECTED]
>
> On Tue, Jul 22, 2003 at 02:59:12PM +0100, Bayley, Alistair wrote:
> > > handler :: Dynamic -> IO ()
> > > handler e = do
> > > case (fromDynamic e) of
> > >Nothing -> putStrLn ("dynamic cast failed")
> > >Just (MkExc n s) -> putStrLn ("
| The above should work, but I wonder when it is possible to simply
derive
| Typeable?
GHC 6.0 supports deriving( Typeable ), but for some strange reason it's
not in the manual. It will be.
Simon
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://
On Tue, Jul 22, 2003 at 02:59:12PM +0100, Bayley, Alistair wrote:
> > handler :: Dynamic -> IO ()
> > handler e = do
> > case (fromDynamic e) of
> >Nothing -> putStrLn ("dynamic cast failed")
> >Just (MkExc n s) -> putStrLn ("exception: " ++ (show n) ++ " " ++ s)
>
> > main :: IO ()
> >
> The documentation for Data.Dynamic is pretty clear for this and I
> believe with GHC6 you can derive Typeable.
>
> {-# NOINLINE myExceptionTyCon #-}
> -- the documentation suggests a fully qualified name
> myExceptionTyCon = mkTyCon "MyException"
>
> instance Typeable MyException where
> t
data MyException = MkExc Int String
... but now it seems I have to install this as an instance of Typeable, and
I don't see how to do that.
instance Typeable MyException where
typeOf ? = ?
import Data.Dynamic
myExceptionTc = mkTyCon "MyException"
instance Typeable MyExceptionBasicSpec where
On Tue, 22 Jul 2003 12:51:24 +0100
"Bayley, Alistair" <[EMAIL PROTECTED]> wrote:
> Exceptions, again...
>
> The docs for Control.Exception say (for Dynamic exceptions): "When
> using dynamic exceptions it is advisable to define a new datatype to
> use for your exception type, to avoid possible cl
Exceptions, again...
The docs for Control.Exception say (for Dynamic exceptions): "When using
dynamic exceptions it is advisable to define a new datatype to use for your
exception type, to avoid possible clashes with dynamic exceptions used in
other libraries."
So I went with that and created a d