(* A bad example with threads. (type error!) *) let printer : unit -> unit = let rec loop (_ : unit) : unit = Thread.delay 100000; putStr "x"; flush (); loop () in loop let startStop : unit -> unit -o unit = fun _: unit -> let id = Thread.fork printer in let id = Thread.print id in fun _: unit -> Thread.kill id let after : int -> (unit -o unit) -> unit = fun delay: int -> fun stop: (unit -o unit) -> Thread.fork (fun _:unit -> Thread.delay delay; stop ()); () let main : unit -> unit = fun _: unit -> let stop = startStop () in after 2000000 stop; getLine (); stop () (* stop used twice! *) in main ()