module Seq: sig
.. end
type 'a
t
An IO stream of values of type 'a, consumable (iterable only once)
val map : ('a -> 'b CCMonadIO.io) -> 'a t -> 'b t
Map values with actions
val map_pure : ('a -> 'b) -> 'a t -> 'b t
Map values with a pure function
val filter_map : ('a -> 'b option) -> 'a t -> 'b t
val filter : ('a -> bool) -> 'a t -> 'a t
val flat_map : ('a -> 'b t CCMonadIO.io) ->
'a t -> 'b t
Map each value to a sub sequence of values
val take : int -> 'a t -> 'a t
val drop : int -> 'a t -> 'a t
val take_while : ('a -> bool CCMonadIO.io) -> 'a t -> 'a t
val drop_while : ('a -> bool CCMonadIO.io) -> 'a t -> 'a t
val general_iter : ('b -> 'a -> [ `Continue of 'b * 'c option | `Stop ] CCMonadIO.io) ->
'b -> 'a t -> 'c t
general_iter f acc seq
performs a filter_map
over seq
,
using f
. f
is given a state and the current value, and
can either return `Stop
to indicate it stops traversing,
or `Continue (st, c)
where st
is the new state and
c
an optional output value.
The result is the stream of values output by f
val tee : ('a -> unit CCMonadIO.io) list -> 'a t -> 'a t
tee funs seq
behaves like seq
, but each element is given to
every function f
in funs
. This function f
returns an action that
is eagerly executed.
Consume
val iter : ('a -> 'b CCMonadIO.io) -> 'a t -> unit CCMonadIO.io
Iterate on the stream, with an action for each element
val length : 'a t -> int CCMonadIO.io
Length of the stream
val fold : ('b -> 'a -> 'b CCMonadIO.io) -> 'b -> 'a t -> 'b CCMonadIO.io
fold f acc seq
folds over seq
, consuming it. Every call to f
has the right to return an IO value.
val fold_pure : ('b -> 'a -> 'b) -> 'b -> 'a t -> 'b CCMonadIO.io
fold f acc seq
folds over seq
, consuming it. f
is pure.
Standard Wrappers
type 'a
step_result =
type 'a
gen = unit -> 'a step_result CCMonadIO.io
val of_fun : 'a gen -> 'a t
Create a stream from a function that yields an element or stops
val empty : 'a t
val singleton : 'a -> 'a t
val cons : 'a -> 'a t -> 'a t
val of_list : 'a list -> 'a t
val of_array : 'a array -> 'a t
val chunks : size:int -> Pervasives.in_channel -> string t
Read the channel's content into chunks of size size
val lines : Pervasives.in_channel -> string t
Lines of an input channel
val words : string t -> string t
Split strings into words at " " boundaries.
NOT IMPLEMENTED
val output : ?sep:string ->
Pervasives.out_channel -> string t -> unit CCMonadIO.io
output oc seq
outputs every value of seq
into oc
, separated
with the optional argument sep
(default: None).
It blocks until all values of seq
are produced and written to oc
.