Reputation: 30283
I'm trying to get past this error to run a command-line utility, without understanding OCaml.
$ dune build
File "_none_", line 1:
Warning 58: no cmx file was found in path for module Toploop, and its interface was not compiled with -opaque
File "vendor/notty/lwt/notty_lwt.ml", line 68, characters 25-64:
Error: This expression has type (unit -> unit) Lwt.t
but an expression was expected of type unit Lwt.t
Hint: Did you forget to provide `()' as argument?
Line 68 looks like this:
Lwt.async (fun () -> Lwt_stream.closed stream >|= fun _ -> f);
And here's the surrounding context, in case it helps:
let input_stream ~nosig fd stop =
let `Revert f = setup_tcattr ~nosig (Lwt_unix.unix_file_descr fd) in
let stream =
let flt = Unescape.create ()
and ibuf = Bytes.create bsize in
let rec next () =
match Unescape.next flt with
| #Unescape.event as r -> Lwt.return_some r
| `End -> Lwt.return_none
| `Await ->
(Lwt_unix.read fd ibuf 0 bsize <??> stop) >>= function
| Left n -> Unescape.input flt ibuf 0 n; next ()
| Right _ -> Lwt.return_none
in Lwt_stream.from next in
Lwt.async (fun () -> Lwt_stream.closed stream >|= fun _ -> f);
stream
Now, I found this other question on Stack Overflow that describes the same error: OCaml: Lwt expression was expected of type unit Lwt.t. Here, the answerer advises replacing
let create_server sock =
let serve () =
Lwt_unix.accept sock >>= accept_connection
in serve (* serve is a function, not a thread *)
with
let create_server sock =
Lwt_unix.accept sock >>= accept_connection
So, how can I do the analogue with my line 68?
If I have to, I'll go and learn some OCaml and this strange syntax that reminds me of lambdas. But all I'm trying to do is install a terminal-based game timer so I can play my game -_-' and I'm already farther down this rabbit-hole than I care to play the game anymore. Any help would be truly appreciated.
Upvotes: 0
Views: 223
Reputation: 7768
Lwt.async (fun () -> Lwt_stream.closed stream >|= fun _ -> f ());
Upvotes: 2