tweaks
authorjim <jim@web>
Tue, 7 Apr 2015 00:06:39 +0000 (20:06 -0400)
committerLinux User <ikiwiki@localhost.members.linode.com>
Tue, 7 Apr 2015 00:06:39 +0000 (20:06 -0400)
topics/_week9_transformers.mdwn

index 24ae852..ff47d06 100644 (file)
@@ -166,6 +166,15 @@ When List is on the inside, the failed results just got dropped and the computat
        - : int LO.result = None
 
 On the other hand, when Option is on the inside, as in LO, failures (which we represent by `mzero`s from the Option monad, here `hoist Monad.Option.mzero`, not the List monad's own `mzero`) abort the whole computation.
        - : int LO.result = None
 
 On the other hand, when Option is on the inside, as in LO, failures (which we represent by `mzero`s from the Option monad, here `hoist Monad.Option.mzero`, not the List monad's own `mzero`) abort the whole computation.
+
+This is fun. Notice the difference it makes whether the second `++` is native to the outer `Monad.List`, or whether it's the inner `Monad.List`'s `++` hoisted into the outer wrapper:
+
+       # module LL = Monad.List.T(Monad.List);;
+
+       # LL.(run((++) (mid 1) (mid 2) >>= fun i -> (++) (mid i) (mid (10*i)) ));;
+       - : int LL.result = \[[1; 10; 2; 20]]
+       # LL.(run((++) (mid 1) (mid 2) >>= fun i -> hoist L.((++) (mid i) (mid (10*i)) )));;
+       - : int LL.result = [[1; 2]; [1; 20]; [10; 2]; [10; 20]]
 -->
 
 <!--
 -->
 
 <!--
@@ -179,15 +188,6 @@ On the other hand, when Option is on the inside, as in LO, failures (which we re
        Exception: Failure "bye".
 -->
 
        Exception: Failure "bye".
 -->
 
-This is fun. Notice the difference it makes whether the second `++` is native to the outer `Monad.List`, or whether it's the inner `Monad.List`'s `++` hoisted into the outer wrapper:
-
-       # module LL = Monad.List.T(Monad.List);;
-
-       # LL.(run((++) (mid 1) (mid 2) >>= fun i -> (++) (mid i) (mid (10*i)) ));;
-       - : int LL.result = \[[1; 10; 2; 20]]
-       # LL.(run((++) (mid 1) (mid 2) >>= fun i -> hoist L.((++) (mid i) (mid (10*i)) )));;
-       - : int LL.result = [[1; 2]; [1; 20]; [10; 2]; [10; 20]]
-
 
 
 Further Reading
 
 
 Further Reading