
I'm writing an application at the moment (in Haskell duh) and the issue of exception handling has come up. I don't want to use Maybe (because that would destructure the code somewhat) or any kind of Monad and I've settled on the idea of SPJs Exception extension. The idea is to create a data type with a different constructor per exception as in data MyException = Ex1 | Ex2 | Ex3 then use throwDyn/catchDyn to throw and catch it. Unfortunately this requires MyException to be an instance of class Typeable, and the documentation on that is quite sparse. Any advice or pointers would be greatly appreciated

On Tue, Nov 28, 2000 at 11:15:14AM +0000, Smelly Pooh wrote:
I'm writing an application at the moment (in Haskell duh) and the issue of exception handling has come up. I don't want to use Maybe (because that would destructure the code somewhat) or any kind of Monad and I've settled on the idea of SPJs Exception extension. The idea is to create a data type with a different constructor per exception as in
data MyException = Ex1 | Ex2 | Ex3
then use throwDyn/catchDyn to throw and catch it. Unfortunately this requires MyException to be an instance of class Typeable, and the documentation on that is quite sparse. Any advice or pointers would be greatly appreciated
\begin{code} data DMsg = DOne | DTwo Int | DThree String | DQuit instance Typeable DMsg where typeOf _ = mkAppTy msgTc [] msgTc :: TyCon msgTc = mkTyCon "Msg" -- To Dynamic: let dyn = toDyn msg -- and back: let msg = fromDynamic dyn case msg of Just _ -> ... Nothing -> error (..) \end{code} -- \usepackage[latin1]{inputenc}! Volker Stolz * stolz@i2.informatik.rwth-aachen.de * PGP + S/MIME
participants (2)
-
Smelly Pooh
-
Volker Stolz