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
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 clashes
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
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
typeOf _ =
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 ()
main = catchDyn temp
| 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]
Simon Peyton-Jones wrote:
GHC 6.0 supports deriving( Typeable ), but for some strange reason it's
not in the manual. It will be.
Yes, I tried it before and gave up after a message:
../HasCASL/As.hs:24:
Can't make a derived instance of `Typeable BasicSpec'
(`Typeable' is not a derivable