329 lines
4.2 KiB
HTML
329 lines
4.2 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of Stream</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>Stream</H1>
|
|
Section: OCaml library (3o)<BR>Updated: 2020-01-30<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
Stream - Streams and parsers.
|
|
<A NAME="lbAC"> </A>
|
|
<H2>Module</H2>
|
|
|
|
Module Stream
|
|
<A NAME="lbAD"> </A>
|
|
<H2>Documentation</H2>
|
|
|
|
<P>
|
|
Module
|
|
<B>Stream</B>
|
|
|
|
<BR> :
|
|
<B>sig end</B>
|
|
|
|
<P>
|
|
<P>
|
|
Streams and parsers.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>type </I>
|
|
|
|
<B>'a</B>
|
|
|
|
<I>t </I>
|
|
|
|
<P>
|
|
<P>
|
|
The type of streams holding values of type
|
|
<B>'a</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>exception Failure </I>
|
|
|
|
<P>
|
|
<P>
|
|
Raised by parsers when none of the first components of the stream
|
|
patterns is accepted.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>exception Error </I>
|
|
|
|
<B>of </B>
|
|
|
|
<B>string</B>
|
|
|
|
<P>
|
|
<P>
|
|
Raised by parsers when the first component of a stream pattern is
|
|
accepted, but one of the following components is rejected.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
|
|
<A NAME="lbAE"> </A>
|
|
<H3>Stream builders</H3>
|
|
|
|
<P>
|
|
<P>
|
|
|
|
<P>
|
|
<I>val from </I>
|
|
|
|
:
|
|
<B>(int -> 'a option) -> 'a t</B>
|
|
|
|
<P>
|
|
<P>
|
|
<B>Stream.from f</B>
|
|
|
|
returns a stream built from the function
|
|
<B>f</B>
|
|
|
|
.
|
|
To create a new stream element, the function
|
|
<B>f</B>
|
|
|
|
is called with
|
|
the current stream count. The user function
|
|
<B>f</B>
|
|
|
|
must return either
|
|
<B>Some <value></B>
|
|
|
|
for a value or
|
|
<B>None</B>
|
|
|
|
to specify the end of the
|
|
stream.
|
|
<P>
|
|
Do note that the indices passed to
|
|
<B>f</B>
|
|
|
|
may not start at
|
|
<B>0</B>
|
|
|
|
in the
|
|
general case. For example,
|
|
<B>[< '0; '1; Stream.from f >]</B>
|
|
|
|
would call
|
|
<B>f</B>
|
|
|
|
the first time with count
|
|
<B>2</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val of_list </I>
|
|
|
|
:
|
|
<B>'a list -> 'a t</B>
|
|
|
|
<P>
|
|
Return the stream holding the elements of the list in the same
|
|
order.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val of_string </I>
|
|
|
|
:
|
|
<B>string -> char t</B>
|
|
|
|
<P>
|
|
Return the stream of the characters of the string parameter.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val of_bytes </I>
|
|
|
|
:
|
|
<B>bytes -> char t</B>
|
|
|
|
<P>
|
|
Return the stream of the characters of the bytes parameter.
|
|
<P>
|
|
<P>
|
|
<B>Since</B>
|
|
|
|
4.02.0
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val of_channel </I>
|
|
|
|
:
|
|
<B>in_channel -> char t</B>
|
|
|
|
<P>
|
|
Return the stream of the characters read from the input channel.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
|
|
<A NAME="lbAF"> </A>
|
|
<H3>Stream iterator</H3>
|
|
|
|
<P>
|
|
<P>
|
|
|
|
<P>
|
|
<I>val iter </I>
|
|
|
|
:
|
|
<B>('a -> unit) -> 'a t -> unit</B>
|
|
|
|
<P>
|
|
<P>
|
|
<B>Stream.iter f s</B>
|
|
|
|
scans the whole stream s, applying function
|
|
<B>f</B>
|
|
|
|
in turn to each stream element encountered.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
|
|
<A NAME="lbAG"> </A>
|
|
<H3>Predefined parsers</H3>
|
|
|
|
<P>
|
|
<P>
|
|
|
|
<P>
|
|
<I>val next </I>
|
|
|
|
:
|
|
<B>'a t -> 'a</B>
|
|
|
|
<P>
|
|
Return the first element of the stream and remove it from the
|
|
stream. Raise
|
|
<B>Stream.Failure</B>
|
|
|
|
if the stream is empty.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val empty </I>
|
|
|
|
:
|
|
<B>'a t -> unit</B>
|
|
|
|
<P>
|
|
Return
|
|
<B>()</B>
|
|
|
|
if the stream is empty, else raise
|
|
<B>Stream.Failure</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
|
|
<A NAME="lbAH"> </A>
|
|
<H3>Useful functions</H3>
|
|
|
|
<P>
|
|
<P>
|
|
|
|
<P>
|
|
<I>val peek </I>
|
|
|
|
:
|
|
<B>'a t -> 'a option</B>
|
|
|
|
<P>
|
|
Return
|
|
<B>Some</B>
|
|
|
|
of "the first element" of the stream, or
|
|
<B>None</B>
|
|
|
|
if
|
|
the stream is empty.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val junk </I>
|
|
|
|
:
|
|
<B>'a t -> unit</B>
|
|
|
|
<P>
|
|
Remove the first element of the stream, possibly unfreezing
|
|
it before.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val count </I>
|
|
|
|
:
|
|
<B>'a t -> int</B>
|
|
|
|
<P>
|
|
Return the current count of the stream elements, i.e. the number
|
|
of the stream elements discarded.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val npeek </I>
|
|
|
|
:
|
|
<B>int -> 'a t -> 'a list</B>
|
|
|
|
<P>
|
|
<P>
|
|
<B>npeek n</B>
|
|
|
|
returns the list of the
|
|
<B>n</B>
|
|
|
|
first elements of
|
|
the stream, or all its remaining elements if less than
|
|
<B>n</B>
|
|
|
|
elements are available.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="1"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="2"><A HREF="#lbAC">Module</A><DD>
|
|
<DT id="3"><A HREF="#lbAD">Documentation</A><DD>
|
|
<DL>
|
|
<DT id="4"><A HREF="#lbAE">Stream builders</A><DD>
|
|
<DT id="5"><A HREF="#lbAF">Stream iterator</A><DD>
|
|
<DT id="6"><A HREF="#lbAG">Predefined parsers</A><DD>
|
|
<DT id="7"><A HREF="#lbAH">Useful functions</A><DD>
|
|
</DL>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:58 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|