Ocsipersistの簡単な使い方

examples/tutoeliom.mlから抜粋してMutex絡みの処理を除いたやつ。

$ cat count3.ml
open Lwt
open XHTML.M
open Eliom_services
open Eliom_parameters
open Eliom_sessions
open Eliom_predefmod.Xhtml

let mystore = Ocsipersist.open_store "db_count3"

let count3 =
  let next =
    let cthr = Ocsipersist.make_persistent mystore "countpage3" 0 in
    (fun () -> cthr >>=
      (fun c -> Ocsipersist.get c >>=
        (fun oldc -> let newc = oldc + 1 in
          Ocsipersist.set c newc >>= (fun () -> return newc))))
  in
  register_new_service
    ~path:["count3"]
    ~get_params:unit
    (fun _ () () ->
      next () >>= (fun n -> return
      (html
        (head (title (pcdata "counter")) [])
        (body [p [pcdata (string_of_int n)]]))))

「>>=」というのはLwt.bindと同意なんだけども、今ひとつLwtを使って嬉しいところが分からない…
let x = t in t' が t >= fun x -> t' みたいに書けるよ、らしいんだけども…

Lwt.wakeup とかを使っているサンプルコードも見たいなぁ。