summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSon Ho2022-01-20 21:49:25 +0100
committerSon Ho2022-01-20 21:49:25 +0100
commit4c25aa1864a4b72ffea7b641b4473029b46b4216 (patch)
tree2406ab7363560085c9c77e613b334be019a1b7e4
parent20ab2fc19efdc7efa9335c28d1e73a22676c6eed (diff)
Add comments
Diffstat (limited to '')
-rw-r--r--src/Cps.ml9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/Cps.ml b/src/Cps.ml
index a09e1ef9..2c515ed0 100644
--- a/src/Cps.ml
+++ b/src/Cps.ml
@@ -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 ->