diff options
author | Son Ho | 2022-01-20 21:49:25 +0100 |
---|---|---|
committer | Son Ho | 2022-01-20 21:49:25 +0100 |
commit | 4c25aa1864a4b72ffea7b641b4473029b46b4216 (patch) | |
tree | 2406ab7363560085c9c77e613b334be019a1b7e4 | |
parent | 20ab2fc19efdc7efa9335c28d1e73a22676c6eed (diff) |
Add comments
Diffstat (limited to '')
-rw-r--r-- | src/Cps.ml | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -126,12 +126,11 @@ let _ = it to `receive`. This is what this function does (see the unit test below for an illustration). - - TODO: use more! *) let comp_transmit (f : ('v -> 'm) -> 'n) (g : 'm -> 'm) : ('v -> 'm) -> 'n = fun cf -> f (fun v -> g (cf v)) +(** Example of use of [comp_transmit] *) let () = let return3 (cf : int -> unit -> unit) (ctx : unit) = cf 3 ctx in let do_nothing (cf : unit -> unit) (ctx : unit) = cf ctx in @@ -143,6 +142,9 @@ let () = let cc = cc consume3 in cc () +(** Sometimes, we want to compose a function with a continuation which checks + its computed value and its updated context, before transmitting them + *) let comp_check_value (f : ('v -> 'ctx -> 'a) -> 'ctx -> 'b) (g : 'v -> 'ctx -> unit) : ('v -> 'ctx -> 'a) -> 'ctx -> 'b = fun cf -> @@ -150,6 +152,9 @@ let comp_check_value (f : ('v -> 'ctx -> 'a) -> 'ctx -> 'b) g v ctx; cf v ctx) +(** This case is similar to [comp_check_value], but even simpler (we only check + the context) + *) let comp_check_ctx (f : ('ctx -> 'a) -> 'ctx -> 'b) (g : 'ctx -> unit) : ('ctx -> 'a) -> 'ctx -> 'b = fun cf -> |