X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=blobdiff_plain;f=topics%2F_week8_using_monads.mdwn;h=9acd123ef81e0d33126f78d94ed51d3e9321fe31;hp=561ce7cde373b412177e649c3354da24a17a758b;hb=a661adb0808f5f8f0f0b3915c7e431bd37f4b65f;hpb=e0b5bee347f3e5efe97e336b91e9200ea95fe6b5 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.