X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=blobdiff_plain;f=manipulating_trees_with_monads.mdwn;h=47fa6f0da08ad5fafebd6f3fec494152a705a175;hp=038cdc3697a4ab501734dac5209ffe2402d0ecd3;hb=f719b082e2cfe4249565a8fb189e983731ada27f;hpb=8f067600295d47935d4ec86e612c189d0e39b0d7 diff --git a/manipulating_trees_with_monads.mdwn b/manipulating_trees_with_monads.mdwn index 038cdc36..47fa6f0d 100644 --- a/manipulating_trees_with_monads.mdwn +++ b/manipulating_trees_with_monads.mdwn @@ -329,7 +329,7 @@ In a moment, we'll return to the same-fringe problem. Since the simple but inefficient way to solve it is to map each tree to a list of its leaves, this transformation is on the path to a more efficient solution. We'll just have to figure out how to postpone computing the -tail of the list until its needed... +tail of the list until it's needed... The Continuation monad is amazingly flexible; we can use it to simulate some of the computations performed above. To see how, first @@ -360,8 +360,14 @@ interesting functions for the first argument of `tree_monadize`: # tree_monadize (fun a -> fun k -> 1 + k a) t1 (fun t -> 0);; - : int = 5 -We could simulate the tree state example too, but it would require -generalizing the type of the Continuation monad to +[To be fixed: exactly which kind of monad each of these computations simulates.] + +We could simulate the tree state example too by setting the relevant +type to `('a, 'state -> 'result) continuation`. +In fact, Andre Filinsky has suggested that the continuation monad is +able to simulate any other monad (Google for "mother of all monads"). + +We would eventually want to generalize the continuation type to type ('a, 'b, 'c) continuation = ('a -> 'b) -> 'c;; @@ -525,7 +531,7 @@ quantification. This sentence means (roughly) - &Forall; x . yesterday(saw x) john + forall x . yesterday(saw x) john That is, the quantifier *everyone* contributes a variable in the direct object position, and a universal quantifier that takes scope @@ -669,7 +675,7 @@ called a that is intended to represent non-deterministic computations as a tree. -What's this have to do with tree\_mondadize? +What's this have to do with tree\_monadize? -------------------------------------------- So we've defined a Tree monad: