Sun, 04 Feb 2001 17:15:16 +1100, Manuel M. T. Chakravarty <chak@cse.unsw.edu.au> pisze:
I am just wondering whether we would want to add the following to `MarshalError':
Maybe throwIf should be changed to failIf? The same function would work for both IO and Maybe.
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. Cheers, Simon
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. CError translates errno to IOError. IOError's representation is private to the Haskell's implementation. Translation of errors other than errno to IOErrors would usually not make much sense anyway, and similarly translation of errno to something other than throwing IOError. -- Marcin 'Qrczak' Kowalczyk
"Marcin 'Qrczak' Kowalczyk" <mk167280@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
Wed, 07 Feb 2001 14:33:01 +1100, Manuel M. T. Chakravarty <chak@cse.unsw.edu.au> pisze:
Hmmm, signature-wise, it doesn't seem that easy (without introducing too much clutter).
OK, I forgot that throwIf takes the monadic computation as an argument and nothingIf takes the value. I still think that nothingIf would be too rarely used. Including every possible convenience wrapper makes the library too big, harder to maintain, harder to find functions in it, harder to understand code which uses so many different functions etc. This one is definitely not that necessary. It would fit better into the Maybe module, as a reverse of the maybe function. (And btw, void should go to module Monad.) I know that it can't happen now because these modules are Haskell98... -- __("< Marcin Kowalczyk * qrczak@knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZASTÊPCZA QRCZAK
participants (4)
-
Manuel M. T. Chakravarty -
Marcin 'Qrczak' Kowalczyk -
qrczak@knm.org.pl -
Simon Marlow