RE: How do I create dynamic exceptions

2003-07-23 Thread Bayley, Alistair
> 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 ("

RE: instance Typeable (Re: How do I create dynamic exceptions)

2003-07-22 Thread Simon Peyton-Jones
| 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://

Re: How do I create dynamic exceptions

2003-07-22 Thread Ross Paterson
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 () > >

RE: How do I create dynamic exceptions

2003-07-22 Thread Bayley, Alistair
> 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

instance Typeable (Re: How do I create dynamic exceptions)

2003-07-22 Thread Christian Maeder
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

Re: How do I create dynamic exceptions

2003-07-22 Thread Derek Elkins
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

How do I create dynamic exceptions

2003-07-22 Thread Bayley, Alistair
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