OCaml implementation of parsing with derivatives