From: jim Date: Sun, 22 Mar 2015 14:26:55 +0000 (-0400) Subject: (no commit message) X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=commitdiff_plain;h=a0ad4f7454eab8673fada7cfb1aa16769605a9a8 --- diff --git a/topics/_week8_using_monads.mdwn b/topics/_week8_using_monads.mdwn index 561ce7cd..9acd123e 100644 --- a/topics/_week8_using_monads.mdwn +++ b/topics/_week8_using_monads.mdwn @@ -180,3 +180,18 @@ material that otherwise would trigger a presupposition violation; but, not surprisingly, these refinements will require some more sophisticated techniques than the super-simple Option/Maybe monad.) + +## Scratch, more... ## + +We've just seen a way to separate thinking about error conditions +(such as trying to divide by zero) from thinking about normal +arithmetic computations. We did this by making use of the `option` +type: in each place where we had something of type `int`, we put +instead something of type `int option`, which is a sum type consisting +either of one choice with an `int` payload, or else a `None` choice +which we interpret as signaling that something has gone wrong. + +The goal was to make normal computing as convenient as possible: when +we're adding or multiplying, we don't have to worry about generating +any new errors, so we would rather not think about the difference +between `int`s and `int option`s.