X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=zipper-lists-continuations.mdwn;h=ed822f88dd77d469d0f648f0b9cd3d1f2709d0ae;hb=4b1834a17fc7a43ea9aa5166afcf5710b65f6856;hp=f0a252ee46d4e5f2141de51c700112c6e12faf16;hpb=25c4a39a52fd98f0df15e3e928795a1972db8f09;p=lambda.git diff --git a/zipper-lists-continuations.mdwn b/zipper-lists-continuations.mdwn index f0a252ee..ed822f88 100644 --- a/zipper-lists-continuations.mdwn +++ b/zipper-lists-continuations.mdwn @@ -245,7 +245,7 @@ Ta da! To bad this digression, though it ties together various elements of the course, has *no relevance whatsoever* to the topic of -continuations. +continuations... Montague's PTQ treatment of DPs as generalized quantifiers ---------------------------------------------------------- @@ -271,10 +271,12 @@ the bind follow naturally. We've done this enough times that we won't belabor the construction of the bind function, the derivation is similar to the List monad just given: - type 'a continuation = ('a -> 'b) -> 'b - c_unit (x:'a) = fun (p:'a -> 'b) -> p x - c_bind (u:('a -> 'b) -> 'b) (f: 'a -> ('c -> 'd) -> 'd): ('c -> 'd) -> 'd = - fun (k:'a -> 'b) -> u (fun (x:'a) -> f x k) +
+type 'a continuation = ('a -> 'b) -> 'b
+c_unit (x:'a) = fun (p:'a -> 'b) -> p x
+c_bind (u:('a -> 'b) -> 'b) (f: 'a -> ('c -> 'd) -> 'd): ('c -> 'd) -> 'd =
+  fun (k:'a -> 'b) -> u (fun (x:'a) -> f x k)
+
How similar is it to the List monad? Let's examine the type constructor and the terms from the list monad derived above: @@ -292,8 +294,6 @@ parallel in a deep sense. To emphasize the parallel, we can instantiate the type of the list' monad using the Ocaml list type: type 'a c_list = ('a -> 'a list) -> 'a list - let c_list_unit x = fun f -> f x;; - let c_list_bind u f = fun k -> u (fun x -> f x k);; Have we really discovered that lists are secretly continuations? Or have we merely found a way of simulating lists using list