package encore

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
val fail : string -> 'a t

fail msg creates a combinator that will always fail with the message msg.

val map : ('a, 'b) Bij.t -> 'a t -> 'b t
val product : 'a t -> 'b t -> ('a * 'b) t
val commit : unit t

commit prevents backtracking beyong the current position of the input, allowing the manager of the input buffer to reuse the preceding bytes for other purposes when the combinator is used as a parser.

As a serializer, commit forces to flush the internal buffer to the manager of the output buffer (if the current state is not into an alteration - see choice).

val fix : ('a t -> 'a t) -> 'a t
val pure : compare:('a -> 'a -> bool) -> 'a -> 'a t
val peek : 'a t -> 'b t -> ('a, 'b) Either.t t

peek p q accepts/computes p and returns it. Otherwise, it accepts/computes q and returns it. It does not advance the input as a parser or produce something into the output as a serializer.

val const : string -> string t
val any : char t

any accepts/produces any character. As a parser, it returns it. As a serializer, it writes it.

val nil : 'a list t
val rep1 : 'a t -> 'a list t

rep1 t runs t one or more times and accepts/produces a list of results from the runs of t.

val rep0 : 'a t -> 'a list t

rep0 t runs t zero of more times and accepts/produces a list of results from the runs of t.

val sep_by0 : sep:unit t -> 'a t -> 'a list t
val sep_by1 : sep:unit t -> 'a t -> 'a list t
val while0 : (char -> bool) -> string t

while0 p accepts/produces a string which respects the predicate p. For example, this description:

NUMBER = *DIGIT

can be translated to:

let number = while0 is_digit 
val while1 : (char -> bool) -> string t

while1 p accepts/produces a string which respects the predicate p. The string must be not empty. This description:

NUMBER = 1*DIGIT

can be translated to:

let number = while1 is_digit 
val fixed : int -> string t

fixed n accepts/produces any string with n bytes.

val choice : 'a t list -> 'a t
val sequence : 'a t list -> 'a list t
val count : int -> 'a t -> 'a list t
val option : 'a t -> 'a option t
val lower : char t

lower accepts/produces any US-ASCII lowercase letter 'a' .. 'z', that is a byte in the range [0x61;0x7A].

val upper : char t

upper accepts/produces any US-ASCII uppercase letter 'A' .. 'Z', that is a byte in the range [0x41;0x5A].

val alpha : char t

alpha is lower <|> upper.

val digit : char t

digit accepts/produces any US-ASCII digit '0' .. '9', that is a byte in the range [0x30;0x39].

val (<$>) : ('a, 'b) Bij.t -> 'a t -> 'b t
val (<|>) : 'a t -> 'a t -> 'a t
val (*>) : unit t -> 'a t -> 'a t
val (<*) : 'a t -> unit t -> 'a t
val (<*>) : 'a t -> 'b t -> ('a * 'b) t
OCaml

Innovation. Community. Security.