1Stream(3)                        OCaml library                       Stream(3)
2
3
4

NAME

6       Stream - Streams and parsers.
7

Module

9       Module   Stream
10

Documentation

12       Module Stream
13        : sig end
14
15
16       Streams and parsers.
17
18
19
20
21
22       type 'a t
23
24
25       The type of streams holding values of type 'a .
26
27
28
29       exception Failure
30
31
32       Raised  by parsers when none of the first components of the stream pat‐
33       terns is accepted.
34
35
36
37       exception Error of string
38
39
40       Raised by parsers when the first  component  of  a  stream  pattern  is
41       accepted, but one of the following components is rejected.
42
43
44
45
46   Stream builders
47       val from : (int -> 'a option) -> 'a t
48
49
50       Stream.from f returns a stream built from the function f .  To create a
51       new stream element, the function f is called with  the  current  stream
52       count.  The user function f must return either Some <value> for a value
53       or None to specify the end of the stream.
54
55       Do note that the indices passed to f may not start at 0 in the  general
56       case.  For  example, [< '0; '1; Stream.from f >] would call f the first
57       time with count 2 .
58
59
60
61       val of_list : 'a list -> 'a t
62
63       Return the stream holding the elements of the list in the same order.
64
65
66
67       val of_string : string -> char t
68
69       Return the stream of the characters of the string parameter.
70
71
72
73       val of_bytes : bytes -> char t
74
75       Return the stream of the characters of the bytes parameter.
76
77
78       Since 4.02.0
79
80
81
82       val of_channel : in_channel -> char t
83
84       Return the stream of the characters read from the input channel.
85
86
87
88
89   Stream iterator
90       val iter : ('a -> unit) -> 'a t -> unit
91
92
93       Stream.iter f s scans the whole stream s, applying function f  in  turn
94       to each stream element encountered.
95
96
97
98
99   Predefined parsers
100       val next : 'a t -> 'a
101
102       Return  the  first element of the stream and remove it from the stream.
103       Raise Stream.Failure if the stream is empty.
104
105
106
107       val empty : 'a t -> unit
108
109       Return () if the stream is empty, else raise Stream.Failure .
110
111
112
113
114   Useful functions
115       val peek : 'a t -> 'a option
116
117       Return Some of "the first element" of the stream, or None if the stream
118       is empty.
119
120
121
122       val junk : 'a t -> unit
123
124       Remove the first element of the stream, possibly unfreezing it before.
125
126
127
128       val count : 'a t -> int
129
130       Return the current count of the stream elements, i.e. the number of the
131       stream elements discarded.
132
133
134
135       val npeek : int -> 'a t -> 'a list
136
137
138       npeek n returns the list of the n first elements of the stream, or  all
139       its remaining elements if less than n elements are available.
140
141
142
143
144
145OCamldoc                          2020-02-27                         Stream(3)
Impressum