The Permissioned module gives the ability to restrict permissions on an array, so
you can give a function read-only access to an array, create an immutable array, etc.
type ('a, -'perms) tThe meaning of the 'perms parameter is as usual (see the Perms 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 sig ... endval bin_t : 'a Bin_prot.Type_class.t ‑> 'perms Bin_prot.Type_class.t ‑> ('a, 'perms) t Bin_prot.Type_class.tval bin_read_t : 'a Bin_prot.Read.reader ‑> 'perms Bin_prot.Read.reader ‑> ('a, 'perms) t Bin_prot.Read.readerval __bin_read_t__ : 'a Bin_prot.Read.reader ‑> 'perms Bin_prot.Read.reader ‑> (Core_kernel__.Import.int ‑> ('a, 'perms) t) Bin_prot.Read.readerval bin_reader_t : 'a Bin_prot.Type_class.reader ‑> 'perms Bin_prot.Type_class.reader ‑> ('a, 'perms) t Bin_prot.Type_class.readerval bin_size_t : 'a Bin_prot.Size.sizer ‑> 'perms Bin_prot.Size.sizer ‑> ('a, 'perms) t Bin_prot.Size.sizerval bin_write_t : 'a Bin_prot.Write.writer ‑> 'perms Bin_prot.Write.writer ‑> ('a, 'perms) t Bin_prot.Write.writerval bin_writer_t : 'a Bin_prot.Type_class.writer ‑> 'perms Bin_prot.Type_class.writer ‑> ('a, 'perms) t Bin_prot.Type_class.writerval bin_shape_t : Bin_prot.Shape.t ‑> Bin_prot.Shape.t ‑> Bin_prot.Shape.tval compare : ('a ‑> 'a ‑> Core_kernel__.Import.int) ‑> ('perms ‑> 'perms ‑> Core_kernel__.Import.int) ‑> ('a, 'perms) t ‑> ('a, 'perms) t ‑> Core_kernel__.Import.intval t_of_sexp : (Base.Sexp.t ‑> 'a) ‑> (Base.Sexp.t ‑> 'perms) ‑> Base.Sexp.t ‑> ('a, 'perms) tval sexp_of_t : ('a ‑> Base.Sexp.t) ‑> ('perms ‑> Base.Sexp.t) ‑> ('a, 'perms) t ‑> Base.Sexp.tmodule Int : sig ... endmodule Float : sig ... endval of_array_id : 'a Core_kernel__.Import.array ‑> ('a, [< Perms.Export.read_write ]) tof_array_id and to_array_id return the same underlying array. On the other
hand, to_array (inherited from Container.S1_permissions below) makes a copy.
To create a new (possibly immutable) copy of an array a, use copy (of_array_id
a). More generally, any function that takes a (possibly mutable) t can be called
on an array by calling of_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:
'a Array.t = 'a array for interoperability with code which
does not use Core.('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.
val to_array_id : ('a, [> Perms.Export.read_write ]) t ‑> 'a Core_kernel__.Import.arrayval to_sequence_immutable : ('a, [> Perms.Export.immutable ]) t ‑> 'a Sequence.tto_sequence_immutable t converts t to a sequence. Unlike to_sequence,
to_sequence_immutable does not need to copy t since it is immutable.
include Container.S1_permissions with type (a, perms) t := (a, perms) tval mem : ('a, [> Perms.Export.read ]) t ‑> 'a ‑> equal:('a ‑> 'a ‑> Core_kernel__.Import.bool) ‑> Core_kernel__.Import.boolChecks whether the provided element is there, using polymorphic compare if equal
is not provided.
val length : (_, [> Perms.Export.read ]) t ‑> Core_kernel__.Import.intval is_empty : (_, [> Perms.Export.read ]) t ‑> Core_kernel__.Import.boolval iter : ('a, [> Perms.Export.read ]) t ‑> f:('a ‑> Core_kernel__.Import.unit) ‑> Core_kernel__.Import.unitval fold : ('a, [> Perms.Export.read ]) t ‑> init:'accum ‑> f:('accum ‑> 'a ‑> 'accum) ‑> 'accumfold t ~init ~f returns f (... f (f (f init e1) e2) e3 ...) en, where e1..en
are the elements of t
val fold_result : ('a, [> Perms.Export.read ]) t ‑> init:'accum ‑> f:('accum ‑> 'a ‑> ('accum, 'e) Result.t) ‑> ('accum, 'e) Result.tfold_result t ~init ~f is a short-circuiting version of fold that runs in the
Result monad. If f returns an Error _, that value is returned without any
additional invocations of f.
val fold_until : ('a, [> Perms.Export.read ]) t ‑> init:'accum ‑> f:('accum ‑> 'a ‑> ('accum, 'final) Container_intf.Continue_or_stop.t) ‑> finish:('accum ‑> 'final) ‑> 'finalfold_until t ~init ~f ~finish is a short-circuiting version of fold. If f
returns Stop _ the computation ceases and results in that value. If f returns
Continue _, the fold will proceed. If f never returns Stop _, the final result
is computed by finish.
val exists : ('a, [> Perms.Export.read ]) t ‑> f:('a ‑> Core_kernel__.Import.bool) ‑> Core_kernel__.Import.boolReturns true if and only if there exists an element for which the provided
function evaluates to true. This is a short-circuiting operation.
val for_all : ('a, [> Perms.Export.read ]) t ‑> f:('a ‑> Core_kernel__.Import.bool) ‑> Core_kernel__.Import.boolReturns true if and only if the provided function evaluates to true for all
elements. This is a short-circuiting operation.
val count : ('a, [> Perms.Export.read ]) t ‑> f:('a ‑> Core_kernel__.Import.bool) ‑> Core_kernel__.Import.intReturns the number of elements for which the provided function evaluates to true.
val sum : (module Core_kernel__.Import.Commutative_group.S with type t = 'sum) ‑> ('a, [> Perms.Export.read ]) t ‑> f:('a ‑> 'sum) ‑> 'sumReturns the sum of f i for i in the container
val find : ('a, [> Perms.Export.read ]) t ‑> f:('a ‑> Core_kernel__.Import.bool) ‑> 'a Core_kernel__.Import.optionReturns as an option the first element for which f evaluates to true.
val find_map : ('a, [> Perms.Export.read ]) t ‑> f:('a ‑> 'b Core_kernel__.Import.option) ‑> 'b Core_kernel__.Import.optionReturns the first evaluation of f that returns Some, and returns None if there
is no such element.
val to_list : ('a, [> Perms.Export.read ]) t ‑> 'a Core_kernel__.Import.listval to_array : ('a, [> Perms.Export.read ]) t ‑> 'a Core_kernel__.Import.arrayval min_elt : ('a, [> Perms.Export.read ]) t ‑> compare:('a ‑> 'a ‑> Core_kernel__.Import.int) ‑> 'a Core_kernel__.Import.optionReturns 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 uses fold so it has the same complexity
as fold. Returns None iff the collection is empty.
val max_elt : ('a, [> Perms.Export.read ]) t ‑> compare:('a ‑> 'a ‑> Core_kernel__.Import.int) ‑> 'a Core_kernel__.Import.optioninclude Blit.S1_permissions with type (a, perms) t := (a, perms) tval blit : (('a, [> Perms.Export.read ]) t, ('a, [> Perms.Export.write ]) t) Base.Blit.blitval blito : (('a, [> Perms.Export.read ]) t, ('a, [> Perms.Export.write ]) t) Base.Blit.blitoval unsafe_blit : (('a, [> Perms.Export.read ]) t, ('a, [> Perms.Export.write ]) t) Base.Blit.blitval sub : (('a, [> Perms.Export.read ]) t, ('a, [< _ Perms.Export.perms ]) t) Base.Blit.subval subo : (('a, [> Perms.Export.read ]) t, ('a, [< _ Perms.Export.perms ]) t) Base.Blit.suboinclude Binary_searchable.S1_permissions with type (a, perms) t := (a, perms) tval binary_search : (('a, [> Perms.Export.read ]) t, 'a, 'key) Base.Binary_searchable.binary_searchval binary_search_segmented : (('a, [> Perms.Export.read ]) t, 'a) Base.Binary_searchable.binary_search_segmentedThese functions are in Container.S1_permissions, but they are re-exposed here so
that their types can be changed to make them more permissive (see comment above).
val length : (_, _) t ‑> Core_kernel__.Import.intval is_empty : (_, _) t ‑> Core_kernel__.Import.boolcounterparts of regular array functions above
external get : ('a, [> Perms.Export.read ]) t ‑> Core_kernel__.Import.int ‑> 'a = "%array_safe_get" external set : ('a, [> Perms.Export.write ]) t ‑> Core_kernel__.Import.int ‑> 'a ‑> Core_kernel__.Import.unit = "%array_safe_set" external unsafe_get : ('a, [> Perms.Export.read ]) t ‑> Core_kernel__.Import.int ‑> 'a = "%array_unsafe_get" external unsafe_set : ('a, [> Perms.Export.write ]) t ‑> Core_kernel__.Import.int ‑> 'a ‑> Core_kernel__.Import.unit = "%array_unsafe_set" val create : len:Core_kernel__.Import.int ‑> 'a ‑> ('a, [< _ Perms.Export.perms ]) tval init : Core_kernel__.Import.int ‑> f:(Core_kernel__.Import.int ‑> 'a) ‑> ('a, [< _ Perms.Export.perms ]) tval make_matrix : dimx:Core_kernel__.Import.int ‑> dimy:Core_kernel__.Import.int ‑> 'a ‑> (('a, [< _ Perms.Export.perms ]) t, [< _ Perms.Export.perms ]) tval append : ('a, [> Perms.Export.read ]) t ‑> ('a, [> Perms.Export.read ]) t ‑> ('a, [< _ Perms.Export.perms ]) tval concat : ('a, [> Perms.Export.read ]) t Core_kernel__.Import.list ‑> ('a, [< _ Perms.Export.perms ]) tval copy : ('a, [> Perms.Export.read ]) t ‑> ('a, [< _ Perms.Export.perms ]) tval fill : ('a, [> Perms.Export.write ]) t ‑> pos:Core_kernel__.Import.int ‑> len:Core_kernel__.Import.int ‑> 'a ‑> Core_kernel__.Import.unitval of_list : 'a Core_kernel__.Import.list ‑> ('a, [< _ Perms.Export.perms ]) tval map : ('a, [> Perms.Export.read ]) t ‑> f:('a ‑> 'b) ‑> ('b, [< _ Perms.Export.perms ]) tval mapi : ('a, [> Perms.Export.read ]) t ‑> f:(Core_kernel__.Import.int ‑> 'a ‑> 'b) ‑> ('b, [< _ Perms.Export.perms ]) tval folding_map : ('a, [> Perms.Export.read ]) t ‑> init:'b ‑> f:('b ‑> 'a ‑> 'b * 'c) ‑> ('c, [< _ Perms.Export.perms ]) tval iteri : ('a, [> Perms.Export.read ]) t ‑> f:(Core_kernel__.Import.int ‑> 'a ‑> Core_kernel__.Import.unit) ‑> Core_kernel__.Import.unitval foldi : ('a, [> Perms.Export.read ]) t ‑> init:'b ‑> f:(Core_kernel__.Import.int ‑> 'b ‑> 'a ‑> 'b) ‑> 'bval folding_mapi : ('a, [> Perms.Export.read ]) t ‑> init:'b ‑> f:(Core_kernel__.Import.int ‑> 'b ‑> 'a ‑> 'b * 'c) ‑> ('c, [< _ Perms.Export.perms ]) tval fold_right : ('a, [> Perms.Export.read ]) t ‑> f:('a ‑> 'b ‑> 'b) ‑> init:'b ‑> 'bval sort : ?pos:Core_kernel__.Import.int ‑> ?len:Core_kernel__.Import.int ‑> ('a, [> Perms.Export.read_write ]) t ‑> compare:('a ‑> 'a ‑> Core_kernel__.Import.int) ‑> Core_kernel__.Import.unitval stable_sort : ('a, [> Perms.Export.read_write ]) t ‑> compare:('a ‑> 'a ‑> Core_kernel__.Import.int) ‑> Core_kernel__.Import.unitval is_sorted : ('a, [> Perms.Export.read ]) t ‑> compare:('a ‑> 'a ‑> Core_kernel__.Import.int) ‑> Core_kernel__.Import.boolval is_sorted_strictly : ('a, [> Perms.Export.read ]) t ‑> compare:('a ‑> 'a ‑> Core_kernel__.Import.int) ‑> Core_kernel__.Import.boolval concat_map : ('a, [> Perms.Export.read ]) t ‑> f:('a ‑> ('b, [> Perms.Export.read ]) t) ‑> ('b, [< _ Perms.Export.perms ]) tval concat_mapi : ('a, [> Perms.Export.read ]) t ‑> f:(Core_kernel__.Import.int ‑> 'a ‑> ('b, [> Perms.Export.read ]) t) ‑> ('b, [< _ Perms.Export.perms ]) tval partition_tf : ('a, [> Perms.Export.read ]) t ‑> f:('a ‑> Core_kernel__.Import.bool) ‑> ('a, [< _ Perms.Export.perms ]) t * ('a, [< _ Perms.Export.perms ]) tval partitioni_tf : ('a, [> Perms.Export.read ]) t ‑> f:(Core_kernel__.Import.int ‑> 'a ‑> Core_kernel__.Import.bool) ‑> ('a, [< _ Perms.Export.perms ]) t * ('a, [< _ Perms.Export.perms ]) tval cartesian_product : ('a, [> Perms.Export.read ]) t ‑> ('b, [> Perms.Export.read ]) t ‑> ('a * 'b, [< _ Perms.Export.perms ]) tval transpose : (('a, [> Perms.Export.read ]) t, [> Perms.Export.read ]) t ‑> (('a, [< _ Perms.Export.perms ]) t, [< _ Perms.Export.perms ]) t Core_kernel__.Import.optionval transpose_exn : (('a, [> Perms.Export.read ]) t, [> Perms.Export.read ]) t ‑> (('a, [< _ Perms.Export.perms ]) t, [< _ Perms.Export.perms ]) tval normalize : (_, _) t ‑> Core_kernel__.Import.int ‑> Core_kernel__.Import.intval slice : ('a, [> Perms.Export.read ]) t ‑> Core_kernel__.Import.int ‑> Core_kernel__.Import.int ‑> ('a, [< _ Perms.Export.perms ]) tval nget : ('a, [> Perms.Export.read ]) t ‑> Core_kernel__.Import.int ‑> 'aval nset : ('a, [> Perms.Export.write ]) t ‑> Core_kernel__.Import.int ‑> 'a ‑> Core_kernel__.Import.unitval filter_opt : ('a Core_kernel__.Import.option, [> Perms.Export.read ]) t ‑> ('a, [< _ Perms.Export.perms ]) tval filter_map : ('a, [> Perms.Export.read ]) t ‑> f:('a ‑> 'b Core_kernel__.Import.option) ‑> ('b, [< _ Perms.Export.perms ]) tval filter_mapi : ('a, [> Perms.Export.read ]) t ‑> f:(Core_kernel__.Import.int ‑> 'a ‑> 'b Core_kernel__.Import.option) ‑> ('b, [< _ Perms.Export.perms ]) tval for_alli : ('a, [> Perms.Export.read ]) t ‑> f:(Core_kernel__.Import.int ‑> 'a ‑> Core_kernel__.Import.bool) ‑> Core_kernel__.Import.boolval existsi : ('a, [> Perms.Export.read ]) t ‑> f:(Core_kernel__.Import.int ‑> 'a ‑> Core_kernel__.Import.bool) ‑> Core_kernel__.Import.boolval counti : ('a, [> Perms.Export.read ]) t ‑> f:(Core_kernel__.Import.int ‑> 'a ‑> Core_kernel__.Import.bool) ‑> Core_kernel__.Import.intval iter2_exn : ('a, [> Perms.Export.read ]) t ‑> ('b, [> Perms.Export.read ]) t ‑> f:('a ‑> 'b ‑> Core_kernel__.Import.unit) ‑> Core_kernel__.Import.unitval map2_exn : ('a, [> Perms.Export.read ]) t ‑> ('b, [> Perms.Export.read ]) t ‑> f:('a ‑> 'b ‑> 'c) ‑> ('c, [< _ Perms.Export.perms ]) tval fold2_exn : ('a, [> Perms.Export.read ]) t ‑> ('b, [> Perms.Export.read ]) t ‑> init:'c ‑> f:('c ‑> 'a ‑> 'b ‑> 'c) ‑> 'cval for_all2_exn : ('a, [> Perms.Export.read ]) t ‑> ('b, [> Perms.Export.read ]) t ‑> f:('a ‑> 'b ‑> Core_kernel__.Import.bool) ‑> Core_kernel__.Import.boolval exists2_exn : ('a, [> Perms.Export.read ]) t ‑> ('b, [> Perms.Export.read ]) t ‑> f:('a ‑> 'b ‑> Core_kernel__.Import.bool) ‑> Core_kernel__.Import.boolval filter : ('a, [> Perms.Export.read ]) t ‑> f:('a ‑> Core_kernel__.Import.bool) ‑> ('a, [< _ Perms.Export.perms ]) tval filteri : ('a, [> Perms.Export.read ]) t ‑> f:(Core_kernel__.Import.int ‑> 'a ‑> Core_kernel__.Import.bool) ‑> ('a, [< _ Perms.Export.perms ]) tval swap : ('a, [> Perms.Export.read_write ]) t ‑> Core_kernel__.Import.int ‑> Core_kernel__.Import.int ‑> Core_kernel__.Import.unitval rev_inplace : ('a, [> Perms.Export.read_write ]) t ‑> Core_kernel__.Import.unitval of_list_rev : 'a Core_kernel__.Import.list ‑> ('a, [< _ Perms.Export.perms ]) tval of_list_map : 'a Core_kernel__.Import.list ‑> f:('a ‑> 'b) ‑> ('b, [< _ Perms.Export.perms ]) tval of_list_rev_map : 'a Core_kernel__.Import.list ‑> f:('a ‑> 'b) ‑> ('b, [< _ Perms.Export.perms ]) tval replace : ('a, [> Perms.Export.read_write ]) t ‑> Core_kernel__.Import.int ‑> f:('a ‑> 'a) ‑> Core_kernel__.Import.unitval replace_all : ('a, [> Perms.Export.read_write ]) t ‑> f:('a ‑> 'a) ‑> Core_kernel__.Import.unitval map_inplace : ('a, [> Perms.Export.read_write ]) t ‑> f:('a ‑> 'a) ‑> Core_kernel__.Import.unitval find_exn : ('a, [> Perms.Export.read ]) t ‑> f:('a ‑> Core_kernel__.Import.bool) ‑> 'aval find_map_exn : ('a, [> Perms.Export.read ]) t ‑> f:('a ‑> 'b Core_kernel__.Import.option) ‑> 'bval findi : ('a, [> Perms.Export.read ]) t ‑> f:(Core_kernel__.Import.int ‑> 'a ‑> Core_kernel__.Import.bool) ‑> (Core_kernel__.Import.int * 'a) Core_kernel__.Import.optionval findi_exn : ('a, [> Perms.Export.read ]) t ‑> f:(Core_kernel__.Import.int ‑> 'a ‑> Core_kernel__.Import.bool) ‑> Core_kernel__.Import.int * 'aval find_mapi : ('a, [> Perms.Export.read ]) t ‑> f:(Core_kernel__.Import.int ‑> 'a ‑> 'b Core_kernel__.Import.option) ‑> 'b Core_kernel__.Import.optionval find_mapi_exn : ('a, [> Perms.Export.read ]) t ‑> f:(Core_kernel__.Import.int ‑> 'a ‑> 'b Core_kernel__.Import.option) ‑> 'bval find_consecutive_duplicate : ('a, [> Perms.Export.read ]) t ‑> equal:('a ‑> 'a ‑> Core_kernel__.Import.bool) ‑> ('a * 'a) Core_kernel__.Import.optionval reduce : ('a, [> Perms.Export.read ]) t ‑> f:('a ‑> 'a ‑> 'a) ‑> 'a Core_kernel__.Import.optionval reduce_exn : ('a, [> Perms.Export.read ]) t ‑> f:('a ‑> 'a ‑> 'a) ‑> 'aval permute : ?random_state:Core_kernel__.Import.Random.State.t ‑> ('a, [> Perms.Export.read_write ]) t ‑> Core_kernel__.Import.unitval zip : ('a, [> Perms.Export.read ]) t ‑> ('b, [> Perms.Export.read ]) t ‑> ('a * 'b, [< _ Perms.Export.perms ]) t Core_kernel__.Import.optionval zip_exn : ('a, [> Perms.Export.read ]) t ‑> ('b, [> Perms.Export.read ]) t ‑> ('a * 'b, [< _ Perms.Export.perms ]) tval unzip : ('a * 'b, [> Perms.Export.read ]) t ‑> ('a, [< _ Perms.Export.perms ]) t * ('b, [< _ Perms.Export.perms ]) tval sorted_copy : ('a, [> Perms.Export.read ]) t ‑> compare:('a ‑> 'a ‑> Core_kernel__.Import.int) ‑> ('a, [< _ Perms.Export.perms ]) tval last : ('a, [> Perms.Export.read ]) t ‑> 'aval empty : Core_kernel__.Import.unit ‑> ('a, [< _ Perms.Export.perms ]) tval equal : ('a, [> Perms.Export.read ]) t ‑> ('a, [> Perms.Export.read ]) t ‑> equal:('a ‑> 'a ‑> Core_kernel__.Import.bool) ‑> Core_kernel__.Import.boolval unsafe_truncate : (_, [> Perms.Export.write ]) t ‑> len:Core_kernel__.Import.int ‑> Core_kernel__.Import.unitval to_sequence : ('a, [> Perms.Export.read ]) t ‑> 'a Sequence.tval to_sequence_mutable : ('a, [> Perms.Export.read ]) t ‑> 'a Sequence.t