ocamlocsigen

What does 'unit' mean in such a type definition?


type waiter =
    { w_wait : unit Lwt.t;
      w_waker: unit Lwt.u option;
      mutable w_did_wait : bool }

I don't understand why there are "unit" in w_wait and w_waker?


Solution

  • According to Lwt's doc the type 'a Lwt.t is the "type of threads returning a result of type 'a.", so your w_wait is a cooperative thread returning unit (i.e. having only side effects). Likewise 'a Lwt.u is the "type of thread wakeners".

    I don't understand what you don't understand in Lwt documentation. It seems quite understandable to me.