I’m trying to collect user input by use of the following function:
let promptString ?(msg=None) s =
let prompt = match msg with
| Some msg -> msg
| None -> String.capitalize_ascii s
in
print_string @@ prompt ^ ": ";
flush stdout;
let value = read_line () in
Val (s, String value)
However, when running the program, the prompt never gets printed before attempting to read a line. I call this function 3 times, and it accepts 3 line inputs before finally flushing the prompt text. Any idea how to fix this?