From a24d1a15858df9574e491bf952a59e700cc75ecc Mon Sep 17 00:00:00 2001 From: Hugo Herbelin Date: Mon, 5 Apr 2021 16:23:35 +0200 Subject: LStream: a library for streams with non-canonical locations. --- lib/lStream.mli | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 lib/lStream.mli (limited to 'lib/lStream.mli') diff --git a/lib/lStream.mli b/lib/lStream.mli new file mode 100644 index 0000000000..fc9b5b5ce1 --- /dev/null +++ b/lib/lStream.mli @@ -0,0 +1,55 @@ +(************************************************************************) +(* * The Coq Proof Assistant / The Coq Development Team *) +(* v * Copyright INRIA, CNRS and contributors *) +(* (int -> ('a * Loc.t) option) -> 'a t + +(** Returning the loc of the last consumed element or the initial loc + if no element is consumed *) +val current_loc : 'a t -> Loc.t + +(** Returning the loc of the max visited element or the initial loc + if no element is consumed *) +val max_peek_loc : 'a t -> Loc.t + +(** Returning the loc starting after element [bp] (counting from 0) + and spanning up to already peeked element at position [ep], under + the assumption that [bp] <= [ep]; returns an empty interval if + [bp] = [ep]; returns the empty initial interval if additionally + [bp] = 0; fails if the elements have not been peeked yet *) +val interval_loc : int -> int -> 'a t -> Loc.t + +(** Return location of an already peeked element at some position counting from 0; + fails if the element has not been peeked yet *) +val get_loc : int -> 'a t -> Loc.t + +(** Lifted usual function on streams *) + +val count : 'a t -> int + +val peek : 'a t -> 'a option + +val npeek : int -> 'a t -> 'a list + +val junk : 'a t -> unit + (** consumes the next element if there is one *) + +val next : 'a t -> 'a + (** [next strm] returns and consumes the next element; + raise [Stream.Failure] if the stream is empty *) + +(** Other functions *) + +val peek_nth : int -> 'a t -> 'a + (** [peek_nth n strm] returns the nth element counting from 0 without + consuming the stream; raises [Stream.Failure] if not enough + elements *) -- cgit v1.2.3