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

NAME

6       Stdlib.Stream - no description
7

Module

9       Module   Stdlib.Stream
10

Documentation

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