Re: instance Typeable

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

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

Re: lazy Printing question

2003-07-22 Thread Wolfgang Jeltsch
On Monday, 2003-07-21, 14:36, CEST, David Roundy wrote: > [...] > My guess would be to try running > > main = putStr $ unlines $ map show $ filter magicP sqs > > It may be that print is doing something like checking the length of the list > which would of course not allow for lazy printing. Is pr

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