Module Base__.With_return

type -'a return = private {
return : b. 'a -> 'b;
}
val with_return : ('a return -> 'a) -> 'a
val with_return_option : ('a return -> unit) -> 'a option

Note that with_return_option allocates ~5 words more than the equivalent with_return call.

val prepend : 'a return -> f:('b -> 'a) -> 'b return

prepend a ~f returns a value x such that each call to x.return first applies f before applying a.return. The call to f is "prepended" to the call to the original a.return. A possible use case is to hand x over to another function which returns 'b, a subtype of 'a, or to capture a common transformation f applied to returned values at several call sites.