Created
August 1, 2014 18:45
-
-
Save pveber/3df7dd1af7523cdd11dd to your computer and use it in GitHub Desktop.
Count lines with async (ocaml)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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