module Shtream:Base module for shtreams, an abstraction of producers of typed data.sig..end
Shtreams are modeled on the standard library's Stream module, but
provide additional features. The main difference is that a shtream
is easily converted to and from another kind of data source: an
in_channel. A shtream may be constructed from a channel (or a data
source such as a command to run) by providing a reader to extract
shtream elements from the in_channel. When converting a shtream
back to a channel with Shtream.channel_of, if the shtream was
constructed from a channel in the first place, that channel is
returned, but if some of the shtream construction is happening
internally, a child process is spawned to compute the shtream
asynchronously.
Operations in this module are all
indifferent to the type of elements in the Shtream.t.
See modules AnyShtream, LineShtream, and StringShtream for
operations specialized on the element type.
Most shtream operations are common to all Shtream modules; these
may also be found in Shtream.COMMON.
exception Failure
Shtream.t. Callbacks such as the argument to Shtream.from
or Shtream.map may raise this to indicate the end of the
shtream they are producing.type 'a t
'aexception CoFailure
type 'a co_t
'aval from : (int -> 'a option) -> 'a tval close : 'a t -> unitval of_list : 'a list -> 'a tval list_of : 'a t -> 'a listval of_stream : 'a Stream.t -> 'a tval stream_of : 'a t -> 'a Stream.tval npeek : ?n:int -> 'a t -> 'a listval peek : ?n:int -> 'a t -> 'a optionval empty : 'a t -> unitval is_empty : 'a t -> boolval status : 'a t -> Proc.status optionval junk : ?n:int -> 'a t -> unitval next : 'a t -> 'aval next' : 'a t -> 'a optionval iter : ('a -> unit) -> 'a t -> unitval filter : ('a -> bool) -> 'a t -> 'a tval map : ('a -> 'b) -> 'a t -> 'b tval concat_map : ('a -> 'b list) -> 'a t -> 'b tval fold_left : ('a -> 'b -> 'a) -> 'a -> 'b t -> 'aval fold_right : ('a -> 'b Lazy.t -> 'b) -> 'a t -> 'b -> 'bval nil : unit -> 'a tval insert : 'a -> 'a t -> unitval cons : 'a -> 'a t -> 'a tval append : 'a t -> 'a t -> 'a tval try_again : unit -> 'aval warn : ('a, unit, string, 'b) Pervasives.format4 -> 'aval fail_with : Proc.status -> 'atypeerror_handler =[ `Exception of exn | `Warning of string ] -> unit
warn s then the error handler receives `Warning s. If
a shtream generator raises an exception e, then the error_handler
receives `Exception e.val current_error_handler : error_handler Pervasives.refval ignore_errors : error_handlerval warn_on_errors : error_handlerval die_on_errors : error_handlerval die_silently_on_errors : error_handlerval coshtream_of : ?procref:Channel.procref -> ('a t -> 'b) -> 'a co_tval conil : unit -> 'a co_tval conext : 'a co_t -> 'a -> unitval coclose : 'a co_t -> unitval annihilate : 'a t -> 'a co_t -> unitval from_low : ?close:(unit -> unit) -> (int -> 'a) -> 'a tval claim : 'a t -> 'a tval set_reader : 'a t -> (Pervasives.in_channel -> 'a) -> unitval hint_reader : 'a t -> Reader.t -> unittypeprotector =Util.protector
Util.protectorval add_protection : protector -> 'a t -> unitval add_cleanup : (unit -> unit) -> 'a t -> unitval channel_of : ?procref:Channel.procref ->
?before:(unit -> unit) ->
?after:(unit -> unit) ->
('a -> unit) -> 'a t -> Pervasives.in_channelval of_channel : ?hint:(Reader.raw_line -> 'a) ->
(Pervasives.in_channel -> 'a) -> Pervasives.in_channel -> 'a tval of_file : ?hint:(Reader.raw_line -> 'a) ->
(Pervasives.in_channel -> 'a) -> string -> 'a tval of_command : ?procref:Channel.procref ->
?dups:Channel.dup_spec ->
?hint:(Reader.raw_line -> 'a) ->
(Pervasives.in_channel -> 'a) -> string -> 'a tval of_program : ?procref:Channel.procref ->
?dups:Channel.dup_spec ->
?hint:(Reader.raw_line -> 'a) ->
(Pervasives.in_channel -> 'a) ->
?path:bool -> string -> ?argv0:string -> string list -> 'a tval of_thunk : ?procref:Channel.procref ->
?dups:Channel.dup_spec ->
?hint:(Reader.raw_line -> 'a) ->
(Pervasives.in_channel -> 'a) -> (unit -> unit) -> 'a tmodule type COMMON =sig..end