> would it be a solution if you defined
> 
> > data RetVal b a = Result a | Exception b 
> 
> in this case you could say
> 
> > instance Monad (RetVal b) where
> >   return = Result
> >   Result x >>= f = f x
> >   Exception x >>= f = Exception x

Incidentally, the predefined data type `Either' may be used for this
purpose.

> instance Monad (Either a) where
>     Left  a >>= k     =  Left a
>     Right a >>= k     =  k a
>     return            =  Right
>
> raise                 :: a -> Either a b
> raise s               =  Left s

`Right' means ok ;-).

Cheers, Ralf

PS: Hallo Peter.


Reply via email to