Module Batteries.Return

module Return: BatReturn

type 'a t 

A label which may be used to return values of type 'a

val label : ('a t -> 'a) -> 'a

label f creates a new label x and invokes f x. If, during the execution of f, return x v is invoked, the execution of f x stops immediately and label f returns v. Otherwise, if f x terminates normally and returns y, label f returns y.

Calling return x v from outside scope f is a run-time error and causes termination of the program.

val with_label : ('a t -> 'a) -> 'a

as label

val return : 'a t -> 'a -> 'b

Return to a label. return l v returns to the point where label l was obtained and produces value l.

Calling return l v from outside the scope of l (i.e. the call to function label which produced l) is a run-time error and causes termination of the program.