Hi,
I want to write a function that simple echos a user’s input in stdin, until user enter “exit”.
My approach is to define a recursive function and use Async’s Reader module to read user input and recursively call the function.
let rec read_and_print () : unit Deferred.t =
let stdin = Lazy.force Reader.stdin in
print_endline "Enter Message: ";
Reader.read_line stdin
>>| function
| `Eof -> print_endline "error"
| `Ok "exit" -> ()
| `Ok x ->
print_endline x;
read_and_print ()
However, i get this error:
How do I solve this?