1Stream(3)                          OCamldoc                          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
48
49       val from : (int -> 'a option) -> 'a t
50
51
52       Stream.from f returns a stream built from the function f .  To create a
53       new stream element, the function f is called with  the  current  stream
54       count.  The user function f must return either Some <value> for a value
55       or None to specify the end of the stream.
56
57       Do note that the indices passed to f may not start at 0 in the  general
58       case.  For  example, [< '0; '1; Stream.from f >] would call f the first
59       time with count 2 .
60
61
62
63       val of_list : 'a list -> 'a t
64
65       Return the stream holding the elements of the list in the same order.
66
67
68
69       val of_string : string -> char t
70
71       Return the stream of the characters of the string parameter.
72
73
74
75       val of_bytes : bytes -> char t
76
77       Return the stream of the characters of the bytes parameter.
78
79
80       Since 4.02.0
81
82
83
84       val of_channel : Pervasives.in_channel -> char t
85
86       Return the stream of the characters read from the input channel.
87
88
89
90
91       === Stream iterator ===
92
93
94       val iter : ('a -> unit) -> 'a t -> unit
95
96
97       Stream.iter f s scans the whole stream s, applying function f  in  turn
98       to each stream element encountered.
99
100
101
102
103       === Predefined parsers ===
104
105
106       val next : 'a t -> 'a
107
108       Return  the  first element of the stream and remove it from the stream.
109       Raise Stream.Failure if the stream is empty.
110
111
112
113       val empty : 'a t -> unit
114
115       Return () if the stream is empty, else raise Stream.Failure .
116
117
118
119
120       === Useful functions ===
121
122
123       val peek : 'a t -> 'a option
124
125       Return Some of "the first element" of the stream, or None if the stream
126       is empty.
127
128
129
130       val junk : 'a t -> unit
131
132       Remove the first element of the stream, possibly unfreezing it before.
133
134
135
136       val count : 'a t -> int
137
138       Return the current count of the stream elements, i.e. the number of the
139       stream elements discarded.
140
141
142
143       val npeek : int -> 'a t -> 'a list
144
145
146       npeek n returns the list of the n first elements of the stream, or  all
147       its remaining elements if less than n elements are available.
148
149
150
151
152
1532018-04-14                          source:                          Stream(3)
Impressum