Skip to content

Instantly share code, notes, and snippets.

@pveber
Created August 1, 2014 18:45
Show Gist options
  • Save pveber/3df7dd1af7523cdd11dd to your computer and use it in GitHub Desktop.
Save pveber/3df7dd1af7523cdd11dd to your computer and use it in GitHub Desktop.
Count lines with async (ocaml)
open Async.Std
let t fn () =
Reader.open_file fn
>>| Reader.lines
>>= Pipe.fold ~init:0 ~f:(fun n _ -> return (n + 1))
>>= fun n -> return (Print.printf "%d\n" n)
let app = Command.(async Spec.(step (fun t fn -> t fn) +> (anon ("fn" %: string)))) ~summary:"bench" t
let () = Command.run app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment