On Feb 10, 2008 5:05 PM, David Teller <David.Teller@univ-orleans.fr> wrote:
On Sun, 2008-02-10 at 13:47 -0500, Yaron Minsky wrote:I agree that this is the most arguable part of this recommendation
> A couple of quick thoughts about the proposal:
> * I don't understand the motivation behind separating out
> may_fail and status. In the case where no explicit error is
> returned, we're happy to return an ordinary option. Why not
> return a status when we want to return an error condition? And
> I don't understand the argument about wanting to delay
> evaluation until the function result is called. Why is that
> good, and if it's good, why do we still support functions that
> return options? The whole thing seems to add verbosity with
> little gain.
candidate. I introduced it because
* it makes possible to decide at a later stage between several
mechanisms for delivering errors from within libraries
* some of these mechanisms make possible to use fully monadic
exceptionless error management, without the usual high cost of fully
monadic exceptionless error management
I have put together three different implementations for such mechanisms
[1] and an example of fully monadic exceptionless error management [2].
[1]
http://www.univ-orleans.fr/lifo/Members/David.Teller/software/exceptionless/exceptionless.ml
[2]
http://www.univ-orleans.fr/lifo/Members/David.Teller/software/exceptionless/test_monad.ml
*
*
> * I think some attention on nomenclature is in order. In the> libraries Jane Street uses, we have something similar toInteresting question. You are correct that "eval" might make more sense
> status (called "result"), but the type is "Ok of 'a | Error of
> 'b" rather than "Success of 'a | Error of 'b", simply for
> terseness. Also, having a function called "result" which
> converts a "may_fail" into a "status" seems like one name too
> many. I would call both the function and the type the same
> thing (either status or result). Unless, of course, you want
> to imply something material about the operation, in which case
> calling it "eval" or somesuch would make sense.
and I believe nobody would object to "Ok|Error" instead of "Success|
Error". If terseness is a concern, "Bad" might even make a shorter
replacement for "Error", although this would probably be harder to read.
> * I don't understand why this proposal is only for functional
> data types. I didn't find the motivation given in the OSR forMy intuition is that managing errors with ('a, 'b) status (or whatever
> this convincing. I feel like the use of exceptions involves
> roughly the same tradeoffs when you're using imperative and
> functional code. If you have long functional pipelines, doing
> exception handling at each stage is a pain, much as it is if
> you do long sequences of imperative operations. That's why I
> think the goal should not be for the interfaces to be
> "exceptionless" so much as to make it easier to keep track of
> where exceptions might and might not be thrown, so that the
> reader of a piece of code knows where to stop and worry about
> exceptions.
this name may become) is mostly functional in the first place. I have in
mind functions such as Unix.rename, which return nothing but may fail.
Without exceptions, one would need to stop at each step to check if no
error has occurred.
Of course, we can handle this with monadic operators, just as we would
handle errors in functional code. I believe this monadic approach is as
close as we can get to having errors tracked by the type system without
requiring the user to handle them at each step along the road.
Now, I admit that I usually write functional code, so input from people
dealing in imperative code in OCaml would be interesting.
> y
Cheers,
David--
David Teller
Security of Distributed Systems
http://www.univ-orleans.fr/lifo/Members/David.Teller
Angry researcher: French Universities need reforms, but the LRU act brings liquidations.