MarshalError

Manuel M. T. Chakravarty chak at cse.unsw.edu.au
Tue Feb 6 22:33:01 EST 2001


"Marcin 'Qrczak' Kowalczyk" <mk167280 at zodiac.mimuw.edu.pl> wrote,

> On Mon, 5 Feb 2001, Simon Marlow wrote:
> 
> > I don't see that.  Presumably you mean overloading failIf with the Monad
> > class, but `fail' takes a String and in the IO monad we want to raise a
> > real IOError, not just a UserError.
> 
> MarshalError is a "portable" and language-independent error wrapping which
> throws userErrors. This can easily be generalized to an arbitrary Monad.

Hmmm, signature-wise, it doesn't seem that easy (without
introducing too much clutter).  We have

    throwIf :: (a -> Bool) -> (a -> String) -> IO a -> IO a

and

  nothingIf :: (a -> Bool) -> (a -> b     ) -> a    -> Maybe b

Unifying these two has two problems:

(1) In the case, where we want to yield a `Maybe' type, we
    really don't want to wrap the original value already
    into a maybe (differece in the third argument). 

(2) The second argument has a very different meaning in both
    cases.  It produces the error message for `thowIf', but
    specifies a conversion of the result value for
    `nothingIf'.

So, I don't see how we can combine the two.

Cheers,
Manuel




More information about the FFI mailing list