package angstrom-lwt-unix

  1. Overview
  2. Docs
Lwt_unix support for Angstrom

Install

dune-project
 Dependency

Authors

Maintainers

Sources

0.11.2.tar.gz
sha256=f67e7fad1af4a6cce4cc42dbfbba4224b4cc3775b46612969bf67ee914bcf624
md5=4275bc9b14ab9a42d14c3420cda33947

doc/angstrom-lwt-unix/Angstrom_lwt_unix/index.html

Module Angstrom_lwt_unixSource

Sourceval parse : ?pushback:(unit -> unit Lwt.t) -> 'a Angstrom.t -> Lwt_io.input_channel -> (Angstrom.Buffered.unconsumed * ('a, string) result) Lwt.t
Sourceval parse_many : 'a Angstrom.t -> ('a -> unit Lwt.t) -> Lwt_io.input_channel -> (Angstrom.Buffered.unconsumed * (unit, string) result) Lwt.t
Sourceval with_buffered_parse_state : ?pushback:(unit -> unit Lwt.t) -> 'a Angstrom.Buffered.state -> Lwt_io.input_channel -> (Angstrom.Buffered.unconsumed * ('a, string) result) Lwt.t

Useful for resuming a parse that returns unconsumed data. Construct a Buffered.state by using Buffered.parse and provide it into this function. This is essentially what parse_many does, so consider using that if you don't require fine-grained control over how many times you want the parser to succeed.

Usage example:

  parse parser in_channel >>= fun (unconsumed, result) ->
  match result with
  | Ok a ->
    let { buf; off; len } = unconsumed in
    let state = Buffered.parse parser in
    let state = Buffered.feed state (`Bigstring (Bigstringaf.sub ~off ~len buf)) in
    with_buffered_parse_state state in_channel
  | Error err -> failwith err