X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=blobdiff_plain;f=zipper-lists-continuations.mdwn;h=a2603dbad674c97dfae216d022e1cc0f58ce559f;hp=a14ed503a13a2f84b411616c985983115ff04160;hb=89f14f08b65f2eb905065135670fbb1712cb9b16;hpb=9f7e25bd5aa94f5d0cdcd80a1ea0a48ff49a88fe diff --git a/zipper-lists-continuations.mdwn b/zipper-lists-continuations.mdwn index a14ed503..a2603dba 100644 --- a/zipper-lists-continuations.mdwn +++ b/zipper-lists-continuations.mdwn @@ -243,16 +243,9 @@ lists, so that they will print out. Ta da! -Just for mnemonic purposes (sneaking in an instance of eta reduction -to the definition of unit), we can summarize the result as follows: - - type ('a, 'b) list' = ('a -> 'b -> 'b) -> 'b -> 'b - l'_unit x = fun f -> f x - l'_bind u f = fun k -> u (fun x -> f x k) - 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 ---------------------------------------------------------- @@ -278,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: