type ('a, -'perms) t
The meaning of the
'perms
parameter is as usual (see thePerms
module for more details) with the non-obvious difference that you don't need any permissions to extract the length of an array. This was done for simplicity because some information about the length of an array can leak out even if you only have write permissions since you can catch out-of-bounds errors.
include Bin_prot.Binable.S2 with type ('a, -'perms) t := ('a, 'perms) t
val bin_shape_t : Bin_prot.Shape.t -> Bin_prot.Shape.t -> Bin_prot.Shape.t
val bin_size_t : ('a, 'b, ('a, 'perms) t) Bin_prot.Size.sizer2
val bin_write_t : ('a, 'b, ('a, 'perms) t) Bin_prot.Write.writer2
val bin_read_t : ('a, 'b, ('a, 'perms) t) Bin_prot.Read.reader2
val __bin_read_t__ : ('a, 'b, int -> ('a, 'perms) t) Bin_prot.Read.reader2
val bin_writer_t : ('a, 'b, ('a, 'perms) t) Bin_prot.Type_class.S2.writer
val bin_reader_t : ('a, 'b, ('a, 'perms) t) Bin_prot.Type_class.S2.reader
val bin_t : ('a, 'b, ('a, 'perms) t) Bin_prot.Type_class.S2.t
val compare : ('a -> 'a -> Base.Int.t) -> ('perms -> 'perms -> Base.Int.t) -> ('a, 'perms) t -> ('a, 'perms) t -> Base.Int.t
include Ppx_sexp_conv_lib.Sexpable.S2 with type ('a, -'perms) t := ('a, 'perms) t
val t_of_sexp : (Sexplib0.Sexp.t -> 'a) -> (Sexplib0.Sexp.t -> 'b) -> Sexplib0.Sexp.t -> ('a, 'perms) t
val sexp_of_t : ('a -> Sexplib0.Sexp.t) -> ('b -> Sexplib0.Sexp.t) -> ('a, 'perms) t -> Sexplib0.Sexp.t
module Int : sig ... end
module Float : sig ... end
val of_array_id : 'a Base.Array.t -> ('a, [< Perms.Export.read_write ]) t
of_array_id
andto_array_id
return the same underlying array. On the other hand,to_array
(inherited fromContainer.S1_permissions
below) makes a copy.To create a new (possibly immutable) copy of an array
a
, usecopy (of_array_id a)
. More generally, any function that takes a (possibly mutable)t
can be called on an array by callingof_array_id
on it first.There is a conceptual type equality between
'a Array.t
and('a, read_write) Array.Permissioned.t
. The reason for not exposing this as an actual type equality is that we also want:- The type equality
'a Array.t = 'a array
for interoperability with code which does not use Core. - The type
('a, 'perms) Array.Permissioned.t
to be abstract, so that the permission phantom type will have an effect.
Since we don't control the definition of
'a array
, this would require a type('a, 'perms) Array.Permissioned.t
which is abstract, except that('a, read_write) Array.Permissioned.t
is concrete, which is not possible.- The type equality
val to_array_id : ('a, [> Perms.Export.read_write ]) t -> 'a Base.Array.t
val to_sequence_immutable : ('a, [> Perms.Export.immutable ]) t -> 'a Sequence.t
to_sequence_immutable t
convertst
to a sequence. Unliketo_sequence
,to_sequence_immutable
does not need to copyt
since it is immutable.
include Container.S1_permissions with type ('a, 'perms) t := ('a, 'perms) t
val mem : ('a, 'perms) t -> 'a -> equal:('a -> 'a -> Base.Bool.t) -> Base.Bool.t
Checks whether the provided element is there, using polymorphic compare if
equal
is not provided.
val length : ('a, 'perms) t -> Base.Int.t
val is_empty : ('a, 'perms) t -> Base.Bool.t
val iter : ('a, 'perms) t -> f:('a -> Base.Unit.t) -> Base.Unit.t
val fold : ('a, 'perms) t -> init:'accum -> f:('accum -> 'a -> 'accum) -> 'accum
fold t ~init ~f
returnsf (... f (f (f init e1) e2) e3 ...) en
, wheree1..en
are the elements oft
val fold_result : ('a, 'perms) t -> init:'accum -> f:('accum -> 'a -> ('accum, 'e) Result.t) -> ('accum, 'e) Result.t
fold_result t ~init ~f
is a short-circuiting version offold
that runs in theResult
monad. Iff
returns anError _
, that value is returned without any additional invocations off
.
val fold_until : ('a, 'perms) t -> init:'accum -> f:('accum -> 'a -> ('accum, 'final) Container_intf.Continue_or_stop.t) -> finish:('accum -> 'final) -> 'final
fold_until t ~init ~f ~finish
is a short-circuiting version offold
. Iff
returnsStop _
the computation ceases and results in that value. Iff
returnsContinue _
, the fold will proceed. Iff
never returnsStop _
, the final result is computed byfinish
.
val exists : ('a, 'perms) t -> f:('a -> Base.Bool.t) -> Base.Bool.t
Returns
true
if and only if there exists an element for which the provided function evaluates totrue
. This is a short-circuiting operation.
val for_all : ('a, 'perms) t -> f:('a -> Base.Bool.t) -> Base.Bool.t
Returns
true
if and only if the provided function evaluates totrue
for all elements. This is a short-circuiting operation.
val count : ('a, 'perms) t -> f:('a -> Base.Bool.t) -> Base.Int.t
Returns the number of elements for which the provided function evaluates to true.
val sum : (module Base.Container.Summable with type t = 'sum) -> ('a, 'perms) t -> f:('a -> 'sum) -> 'sum
Returns the sum of
f i
for i in the container
val find : ('a, 'perms) t -> f:('a -> Base.Bool.t) -> 'a Base.Option.t
Returns as an
option
the first element for whichf
evaluates to true.
val find_map : ('a, 'perms) t -> f:('a -> 'b Base.Option.t) -> 'b Base.Option.t
Returns the first evaluation of
f
that returnsSome
, and returnsNone
if there is no such element.
val to_list : ('a, 'perms) t -> 'a Base.List.t
val to_array : ('a, 'perms) t -> 'a Base.Array.t
val min_elt : ('a, 'perms) t -> compare:('a -> 'a -> Base.Int.t) -> 'a Base.Option.t
Returns a min (resp max) element from the collection using the provided
compare
function. In case of a tie, the first element encountered while traversing the collection is returned. The implementation usesfold
so it has the same complexity asfold
. ReturnsNone
iff the collection is empty.
val max_elt : ('a, 'perms) t -> compare:('a -> 'a -> Base.Int.t) -> 'a Base.Option.t
include Blit.S1_permissions with type ('a, 'perms) t := ('a, 'perms) t
val blit : (('a, 'perms) t, ('a, 'perms) t) Base.Blit.blit
val blito : (('a, 'perms) t, ('a, 'perms) t) Base.Blit.blito
val unsafe_blit : (('a, 'perms) t, ('a, 'perms) t) Base.Blit.blit
val sub : (('a, 'perms) t, ('a, 'perms) t) Base.Blit.sub
val subo : (('a, 'perms) t, ('a, 'perms) t) Base.Blit.subo
include Binary_searchable.S1_permissions with type ('a, 'perms) t := ('a, 'perms) t
val binary_search : (('a, 'perms) t, 'a, 'key) Base.Binary_searchable.binary_search
val binary_search_segmented : (('a, 'perms) t, 'a) Base.Binary_searchable.binary_search_segmented
val length : (_, _) t -> Base.Int.t
val is_empty : (_, _) t -> Base.Bool.t
val get : ('a, [> Perms.Export.read ]) t -> Base.Int.t -> 'a
val set : ('a, [> Perms.Export.write ]) t -> Base.Int.t -> 'a -> Base.Unit.t
val unsafe_get : ('a, [> Perms.Export.read ]) t -> Base.Int.t -> 'a
val unsafe_set : ('a, [> Perms.Export.write ]) t -> Base.Int.t -> 'a -> Base.Unit.t
val create : len:Base.Int.t -> 'a -> ('a, [< _ Perms.Export.perms ]) t
val init : Base.Int.t -> f:(Base.Int.t -> 'a) -> ('a, [< _ Perms.Export.perms ]) t
val make_matrix : dimx:Base.Int.t -> dimy:Base.Int.t -> 'a -> (('a, [< _ Perms.Export.perms ]) t, [< _ Perms.Export.perms ]) t
val append : ('a, [> Perms.Export.read ]) t -> ('a, [> Perms.Export.read ]) t -> ('a, [< _ Perms.Export.perms ]) t
val concat : ('a, [> Perms.Export.read ]) t Base.List.t -> ('a, [< _ Perms.Export.perms ]) t
val copy : ('a, [> Perms.Export.read ]) t -> ('a, [< _ Perms.Export.perms ]) t
val fill : ('a, [> Perms.Export.write ]) t -> pos:Base.Int.t -> len:Base.Int.t -> 'a -> Base.Unit.t
val of_list : 'a Base.List.t -> ('a, [< _ Perms.Export.perms ]) t
val map : ('a, [> Perms.Export.read ]) t -> f:('a -> 'b) -> ('b, [< _ Perms.Export.perms ]) t
val mapi : ('a, [> Perms.Export.read ]) t -> f:(Base.Int.t -> 'a -> 'b) -> ('b, [< _ Perms.Export.perms ]) t
val folding_map : ('a, [> Perms.Export.read ]) t -> init:'b -> f:('b -> 'a -> 'b * 'c) -> ('c, [< _ Perms.Export.perms ]) t
val iteri : ('a, [> Perms.Export.read ]) t -> f:(Base.Int.t -> 'a -> Base.Unit.t) -> Base.Unit.t
val foldi : ('a, [> Perms.Export.read ]) t -> init:'b -> f:(Base.Int.t -> 'b -> 'a -> 'b) -> 'b
val folding_mapi : ('a, [> Perms.Export.read ]) t -> init:'b -> f:(Base.Int.t -> 'b -> 'a -> 'b * 'c) -> ('c, [< _ Perms.Export.perms ]) t
val fold_right : ('a, [> Perms.Export.read ]) t -> f:('a -> 'b -> 'b) -> init:'b -> 'b
val sort : ?pos:Base.Int.t -> ?len:Base.Int.t -> ('a, [> Perms.Export.read_write ]) t -> compare:('a -> 'a -> Base.Int.t) -> Base.Unit.t
val stable_sort : ('a, [> Perms.Export.read_write ]) t -> compare:('a -> 'a -> Base.Int.t) -> Base.Unit.t
val is_sorted : ('a, [> Perms.Export.read ]) t -> compare:('a -> 'a -> Base.Int.t) -> Base.Bool.t
val is_sorted_strictly : ('a, [> Perms.Export.read ]) t -> compare:('a -> 'a -> Base.Int.t) -> Base.Bool.t
val concat_map : ('a, [> Perms.Export.read ]) t -> f:('a -> ('b, [> Perms.Export.read ]) t) -> ('b, [< _ Perms.Export.perms ]) t
val concat_mapi : ('a, [> Perms.Export.read ]) t -> f:(Base.Int.t -> 'a -> ('b, [> Perms.Export.read ]) t) -> ('b, [< _ Perms.Export.perms ]) t
val partition_tf : ('a, [> Perms.Export.read ]) t -> f:('a -> Base.Bool.t) -> ('a, [< _ Perms.Export.perms ]) t * ('a, [< _ Perms.Export.perms ]) t
val partitioni_tf : ('a, [> Perms.Export.read ]) t -> f:(Base.Int.t -> 'a -> Base.Bool.t) -> ('a, [< _ Perms.Export.perms ]) t * ('a, [< _ Perms.Export.perms ]) t
val cartesian_product : ('a, [> Perms.Export.read ]) t -> ('b, [> Perms.Export.read ]) t -> ('a * 'b, [< _ Perms.Export.perms ]) t
val transpose : (('a, [> Perms.Export.read ]) t, [> Perms.Export.read ]) t -> (('a, [< _ Perms.Export.perms ]) t, [< _ Perms.Export.perms ]) t Base.Option.t
val transpose_exn : (('a, [> Perms.Export.read ]) t, [> Perms.Export.read ]) t -> (('a, [< _ Perms.Export.perms ]) t, [< _ Perms.Export.perms ]) t
val normalize : (_, _) t -> Base.Int.t -> Base.Int.t
val slice : ('a, [> Perms.Export.read ]) t -> Base.Int.t -> Base.Int.t -> ('a, [< _ Perms.Export.perms ]) t
val nget : ('a, [> Perms.Export.read ]) t -> Base.Int.t -> 'a
val nset : ('a, [> Perms.Export.write ]) t -> Base.Int.t -> 'a -> Base.Unit.t
val filter_opt : ('a Base.Option.t, [> Perms.Export.read ]) t -> ('a, [< _ Perms.Export.perms ]) t
val filter_map : ('a, [> Perms.Export.read ]) t -> f:('a -> 'b Base.Option.t) -> ('b, [< _ Perms.Export.perms ]) t
val filter_mapi : ('a, [> Perms.Export.read ]) t -> f:(Base.Int.t -> 'a -> 'b Base.Option.t) -> ('b, [< _ Perms.Export.perms ]) t
val for_alli : ('a, [> Perms.Export.read ]) t -> f:(Base.Int.t -> 'a -> Base.Bool.t) -> Base.Bool.t
val existsi : ('a, [> Perms.Export.read ]) t -> f:(Base.Int.t -> 'a -> Base.Bool.t) -> Base.Bool.t
val counti : ('a, [> Perms.Export.read ]) t -> f:(Base.Int.t -> 'a -> Base.Bool.t) -> Base.Int.t
val iter2_exn : ('a, [> Perms.Export.read ]) t -> ('b, [> Perms.Export.read ]) t -> f:('a -> 'b -> Base.Unit.t) -> Base.Unit.t
val map2_exn : ('a, [> Perms.Export.read ]) t -> ('b, [> Perms.Export.read ]) t -> f:('a -> 'b -> 'c) -> ('c, [< _ Perms.Export.perms ]) t
val fold2_exn : ('a, [> Perms.Export.read ]) t -> ('b, [> Perms.Export.read ]) t -> init:'c -> f:('c -> 'a -> 'b -> 'c) -> 'c
val for_all2_exn : ('a, [> Perms.Export.read ]) t -> ('b, [> Perms.Export.read ]) t -> f:('a -> 'b -> Base.Bool.t) -> Base.Bool.t
val exists2_exn : ('a, [> Perms.Export.read ]) t -> ('b, [> Perms.Export.read ]) t -> f:('a -> 'b -> Base.Bool.t) -> Base.Bool.t
val filter : ('a, [> Perms.Export.read ]) t -> f:('a -> Base.Bool.t) -> ('a, [< _ Perms.Export.perms ]) t
val filteri : ('a, [> Perms.Export.read ]) t -> f:(Base.Int.t -> 'a -> Base.Bool.t) -> ('a, [< _ Perms.Export.perms ]) t
val swap : ('a, [> Perms.Export.read_write ]) t -> Base.Int.t -> Base.Int.t -> Base.Unit.t
val rev_inplace : ('a, [> Perms.Export.read_write ]) t -> Base.Unit.t
val of_list_rev : 'a Base.List.t -> ('a, [< _ Perms.Export.perms ]) t
val of_list_map : 'a Base.List.t -> f:('a -> 'b) -> ('b, [< _ Perms.Export.perms ]) t
val of_list_mapi : 'a Base.List.t -> f:(Base.Int.t -> 'a -> 'b) -> ('b, [< _ Perms.Export.perms ]) t
val of_list_rev_map : 'a Base.List.t -> f:('a -> 'b) -> ('b, [< _ Perms.Export.perms ]) t
val of_list_rev_mapi : 'a Base.List.t -> f:(Base.Int.t -> 'a -> 'b) -> ('b, [< _ Perms.Export.perms ]) t
val map_inplace : ('a, [> Perms.Export.read_write ]) t -> f:('a -> 'a) -> Base.Unit.t
val find_exn : ('a, [> Perms.Export.read ]) t -> f:('a -> Base.Bool.t) -> 'a
val find_map_exn : ('a, [> Perms.Export.read ]) t -> f:('a -> 'b Base.Option.t) -> 'b
val findi : ('a, [> Perms.Export.read ]) t -> f:(Base.Int.t -> 'a -> Base.Bool.t) -> (Base.Int.t * 'a) Base.Option.t
val findi_exn : ('a, [> Perms.Export.read ]) t -> f:(Base.Int.t -> 'a -> Base.Bool.t) -> Base.Int.t * 'a
val find_mapi : ('a, [> Perms.Export.read ]) t -> f:(Base.Int.t -> 'a -> 'b Base.Option.t) -> 'b Base.Option.t
val find_mapi_exn : ('a, [> Perms.Export.read ]) t -> f:(Base.Int.t -> 'a -> 'b Base.Option.t) -> 'b
val find_consecutive_duplicate : ('a, [> Perms.Export.read ]) t -> equal:('a -> 'a -> Base.Bool.t) -> ('a * 'a) Base.Option.t
val reduce : ('a, [> Perms.Export.read ]) t -> f:('a -> 'a -> 'a) -> 'a Base.Option.t
val reduce_exn : ('a, [> Perms.Export.read ]) t -> f:('a -> 'a -> 'a) -> 'a
val permute : ?random_state:Base.Random.State.t -> ('a, [> Perms.Export.read_write ]) t -> Base.Unit.t
val zip : ('a, [> Perms.Export.read ]) t -> ('b, [> Perms.Export.read ]) t -> ('a * 'b, [< _ Perms.Export.perms ]) t Base.Option.t
val zip_exn : ('a, [> Perms.Export.read ]) t -> ('b, [> Perms.Export.read ]) t -> ('a * 'b, [< _ Perms.Export.perms ]) t
val unzip : ('a * 'b, [> Perms.Export.read ]) t -> ('a, [< _ Perms.Export.perms ]) t * ('b, [< _ Perms.Export.perms ]) t
val sorted_copy : ('a, [> Perms.Export.read ]) t -> compare:('a -> 'a -> Base.Int.t) -> ('a, [< _ Perms.Export.perms ]) t
val last : ('a, [> Perms.Export.read ]) t -> 'a
val equal : ('a -> 'a -> Base.Bool.t) -> ('a, [> Perms.Export.read ]) t -> ('a, [> Perms.Export.read ]) t -> Base.Bool.t
val to_sequence : ('a, [> Perms.Export.read ]) t -> 'a Sequence.t
val to_sequence_mutable : ('a, [> Perms.Export.read ]) t -> 'a Sequence.t