(no commit message)
authorjim <jim@web>
Sun, 22 Mar 2015 14:26:55 +0000 (10:26 -0400)
committerLinux User <ikiwiki@localhost.members.linode.com>
Sun, 22 Mar 2015 14:26:55 +0000 (10:26 -0400)
topics/_week8_using_monads.mdwn

index 561ce7c..9acd123 100644 (file)
@@ -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.)
 
 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.