diff --git a/fiber/src/core.ml b/fiber/src/core.ml index 9943c67..d3be7c2 100644 --- a/fiber/src/core.ml +++ b/fiber/src/core.ml @@ -245,6 +245,7 @@ module Var = struct end let of_thunk f k = f () k +let of_thunk_apply f x k = f x k module O = struct let ( >>> ) a b k = a (fun () -> b k) diff --git a/fiber/src/fiber.mli b/fiber/src/fiber.mli index bd4dbca..aeb49d6 100644 --- a/fiber/src/fiber.mli +++ b/fiber/src/fiber.mli @@ -18,12 +18,14 @@ type 'a fiber := 'a t (** Create a fiber that has already terminated. *) val return : 'a -> 'a t -(** Converts a thunk to a fiber, making sure the thunk runs in the context of - the fiber (rather than applied in the current context). - - Equivalent to [(>>=) (return ())], but more explicit. *) +(** Convert a thunk to a Memo computation, making sure the thunk runs in the context of + the Memo computation rather than in the current context. + [of_thunk f] is equivalent to [return () >> f] but is more explicit. *) val of_thunk : (unit -> 'a t) -> 'a t +(** Like [of_thunk] but accepts functions of any argument. *) +val of_thunk_apply : ('a -> 'b t) -> 'a -> 'b t + (** Fiber that never completes. *) val never : 'a t