module Make:
Build a new shtream module. The AnyShtream.ELEM
parameter specifies how to read and print shtream elements.
include Shtream.COMMON
The result of AnyShtream.Make
contains all the type-indifferent
shtream operations from Shtream
.
module Elem: AnyShtream.ELEM
Access to the underlying element type and operations.
type 'a
elem = 'a Elem.elem
type
initial = Elem.initial
Alias for AnyShtream.ELEM.initial
val elem_reader : Reader.t ->
Pervasives.in_channel ->
initial elem
val output : ?channel:Pervasives.out_channel ->
?init:('a elem -> string) ->
?term:('a elem -> string) ->
?show:('a elem -> string) ->
'a elem t -> unit
Write the entire contents of a shtream on a channel.
For each element x
of the shtream, it prints init x
, then
show x
, and then term x
on the channel, and then flushes the
channel.
channel
: default = stdout
init
: default = fun _ -> ""
term
: default = fun _ -> "\n"
show
: default = Elem.string_of ()
val channel_of : ?procref:Channel.procref ->
?before:(unit -> unit) ->
?after:(unit -> unit) ->
?init:('a elem -> string) ->
?term:('a elem -> string) ->
?show:('a elem -> string) ->
'a elem t -> Pervasives.in_channel
Construct an
in_channel
from the data in a
shtream. If forking a child is necessary (see
Shtream.channel_of
), then the optional
parameter
?before
(resp.
?after
) is called in the child
before (resp. after) printing the shtream; anything printed on
stdout
by
?before
(
?after
) appears in the resultant
in_channel
before (after) the shtream data.
The remaining arguments are as for AnyShtream.ANYSHTREAM.output
.
val string_list_of : ?show:('a elem -> string) ->
'a elem t -> string list
Convert a shtream to a list of strings, using ?show
.
val string_stream_of : ?show:('a elem -> string) ->
'a elem t -> string Stream.t
Convert a shtream to a standard library Stream.t
of
strings, using ?show
.
val of_channel : ?reader:(Pervasives.in_channel ->
initial elem) ->
Pervasives.in_channel ->
initial elem t
Read a shtream from a channel, using ?reader
.
val of_file : ?reader:(Pervasives.in_channel ->
initial elem) ->
string -> initial elem t
Read a shtream from a file, using ?reader
.
val of_command : ?procref:Channel.procref ->
?dups:Channel.dup_spec ->
?reader:(Pervasives.in_channel ->
initial elem) ->
string -> initial elem t
Read a shtream from the output of a command, using
?reader
.
If
?procref
is given, stash the
Proc.t
; if
?dups
is given, perform the dups in the child process.
val of_program : ?procref:Channel.procref ->
?dups:Channel.dup_spec ->
?reader:(Pervasives.in_channel ->
initial elem) ->
?path:bool ->
string ->
?argv0:string ->
string list -> initial elem t
Read a shtream from the output of a process, using
?reader
.
If
?procref
is given, stash the
Proc.t
; if
?dups
is given, perform the dups in the child process.
val of_thunk : ?procref:Channel.procref ->
?dups:Channel.dup_spec ->
?reader:(Pervasives.in_channel ->
initial elem) ->
(unit -> unit) -> initial elem t
Read a shtream from the output of a thunk, using
?reader
.
If
?procref
is given, stash the
Proc.t
; if
?dups
is given, perform the dups in the child process.
val of_string_list : ?parse:(string -> initial elem) ->
string list -> initial elem t
Construct a shtream from a list of strings, using ?parse
.
val of_string_stream : ?parse:(string -> initial elem) ->
string Stream.t -> initial elem t
Construct a shtream from a standard
library Stream.t
of strings, using ?parse
.