package core

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Array.PermissionedSource

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.

Sourcetype ('a, -'perms) t

The 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 Bin_prot.Binable.S_local2 with type ('a, -'perms) t := ('a, 'perms) t
include Bin_prot.Binable.S2 with type ('a, -'perms) t := ('a, 'perms) t
Sourceval bin_size_t : ('a, 'b, ('a, 'b) t) Bin_prot.Size.sizer2
Sourceval bin_write_t : ('a, 'b, ('a, 'b) t) Bin_prot.Write.writer2
Sourceval bin_read_t : ('a, 'b, ('a, 'b) t) Bin_prot.Read.reader2
Sourceval __bin_read_t__ : ('a, 'b, int -> ('a, 'b) t) Bin_prot.Read.reader2
Sourceval bin_writer_t : ('a, 'b, ('a, 'b) t) Bin_prot.Type_class.S2.writer
Sourceval bin_reader_t : ('a, 'b, ('a, 'b) t) Bin_prot.Type_class.S2.reader
Sourceval bin_t : ('a, 'b, ('a, 'b) t) Bin_prot.Type_class.S2.t
Sourceval bin_size_t__local : ('a, 'b, ('a, 'b) t) Bin_prot.Size.sizer_local2
Sourceval bin_write_t__local : ('a, 'b, ('a, 'b) t) Bin_prot.Write.writer_local2
include Ppx_compare_lib.Comparable.S2 with type ('a, -'perms) t := ('a, 'perms) t
Sourceval compare : ('a -> 'a -> int) -> ('b -> 'b -> int) -> ('a, 'b) t -> ('a, 'b) t -> int
include Sexplib0.Sexpable.S2 with type ('a, -'perms) t := ('a, 'perms) t
Sourceval t_of_sexp : (Sexplib0.Sexp.t -> 'a) -> (Sexplib0.Sexp.t -> 'b) -> Sexplib0.Sexp.t -> ('a, 'b) t
Sourceval sexp_of_t : ('a -> Sexplib0.Sexp.t) -> ('b -> Sexplib0.Sexp.t) -> ('a, 'b) t -> Sexplib0.Sexp.t
Sourcemodule Int : sig ... end
Sourcemodule Float : sig ... end
Sourceval of_array_id : 'a Base.Array.t -> ('a, [< Perms.Export.read_write ]) t

of_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:

  • 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.

Sourceval to_array_id : ('a, [> Perms.Export.read_write ]) t -> 'a Base.Array.t
Sourceval to_sequence_immutable : ('a, [> Perms.Export.immutable ]) t -> 'a Sequence.t

to_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 Indexed_container.S1_with_creators_permissions with type ('a, 'perms) t := ('a, 'perms) t
include Container.S1_with_creators_permissions with type ('a, 'perms) t := ('a, 'perms) t
include Container_intf.S1_permissions with type ('a, 'perms) t := ('a, 'perms) t
Sourceval of_array : 'a Base.Array.t -> ('a, [< _ Perms.Export.perms ]) t
Sourceval partition_map : ('a, [> Perms.Export.read ]) t -> f:('a -> ('b, 'c) Either.t) -> ('b, [< _ Perms.Export.perms ]) t * ('c, [< _ Perms.Export.perms ]) t
include Container.S1_permissions with type ('a, 'perms) t := ('a, 'perms) t
Sourceval mem : ('a, [> Perms.Export.read ]) t -> 'a -> equal:('a -> 'a -> Base.Bool.t) -> Base.Bool.t

Checks whether the provided element is there.

Sourceval iter : ('a, [> Perms.Export.read ]) t -> f:('a -> Base.Unit.t) -> Base.Unit.t

iter t ~f calls f on each element of t.

Sourceval fold : ('a, [> Perms.Export.read ]) t -> init:'acc -> f:('acc -> 'a -> 'acc) -> 'acc

fold t ~init ~f returns f (... f (f (f init e1) e2) e3 ...) en, where e1..en are the elements of t

Sourceval fold_result : ('a, [> Perms.Export.read ]) t -> init:'acc -> f:('acc -> 'a -> ('acc, 'e) Result.t) -> ('acc, 'e) Result.t

fold_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.

Sourceval fold_until : ('a, [> Perms.Export.read ]) t -> init:'acc -> f:('acc -> 'a -> ('acc, 'final) Base.Container.Continue_or_stop.t) -> finish:('acc -> 'final) -> 'final

fold_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.

Sourceval exists : ('a, [> Perms.Export.read ]) 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 to true. This is a short-circuiting operation.

Sourceval for_all : ('a, [> Perms.Export.read ]) t -> f:('a -> Base.Bool.t) -> Base.Bool.t

Returns true if and only if the provided function evaluates to true for all elements. This is a short-circuiting operation.

Sourceval count : ('a, [> Perms.Export.read ]) t -> f:('a -> Base.Bool.t) -> Base.Int.t

Returns the number of elements for which the provided function evaluates to true.

Sourceval sum : (module Base.Container.Summable with type t = 'sum) -> ('a, [> Perms.Export.read ]) t -> f:('a -> 'sum) -> 'sum

Returns the sum of f i for i in the container

Sourceval find : ('a, [> Perms.Export.read ]) t -> f:('a -> Base.Bool.t) -> 'a Base.Option.t

Returns as an option the first element for which f evaluates to true.

Sourceval find_map : ('a, [> Perms.Export.read ]) t -> f:('a -> 'b Base.Option.t) -> 'b Base.Option.t

Returns the first evaluation of f that returns Some, and returns None if there is no such element.

Sourceval to_list : ('a, [> Perms.Export.read ]) t -> 'a Base.List.t
Sourceval to_array : ('a, [> Perms.Export.read ]) t -> 'a Base.Array.t
Sourceval min_elt : ('a, [> Perms.Export.read ]) 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 uses fold so it has the same complexity as fold. Returns None iff the collection is empty.

Sourceval max_elt : ('a, [> Perms.Export.read ]) t -> compare:('a -> 'a -> Base.Int.t) -> 'a Base.Option.t
include Blit.S1_permissions with type ('a, 'perms) t := ('a, 'perms) t
Sourceval blit : (('a, [> Perms.Export.read ]) t, ('a, [> Perms.Export.write ]) t) Base.Blit.blit
Sourceval blito : (('a, [> Perms.Export.read ]) t, ('a, [> Perms.Export.write ]) t) Base.Blit.blito
Sourceval unsafe_blit : (('a, [> Perms.Export.read ]) t, ('a, [> Perms.Export.write ]) t) Base.Blit.blit
Sourceval sub : (('a, [> Perms.Export.read ]) t, ('a, [< _ Perms.Export.perms ]) t) Base.Blit.sub
Sourceval subo : (('a, [> Perms.Export.read ]) t, ('a, [< _ Perms.Export.perms ]) t) Base.Blit.subo
include Binary_searchable.S1_permissions with type ('a, 'perms) t := ('a, 'perms) t
Sourceval binary_search_segmented : (('a, [> Perms.Export.read ]) t, 'a) Base.Binary_searchable.binary_search_segmented

These 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).

Sourceval length : (_, _) t -> Base.Int.t
Sourceval is_empty : (_, _) t -> Base.Bool.t

counterparts of regular array functions above

Sourceval get : ('a, [> Perms.Export.read ]) t -> Base.Int.t -> 'a
Sourceval set : ('a, [> Perms.Export.write ]) t -> Base.Int.t -> 'a -> Base.Unit.t
Sourceval unsafe_get : ('a, [> Perms.Export.read ]) t -> Base.Int.t -> 'a
Sourceval unsafe_set : ('a, [> Perms.Export.write ]) t -> Base.Int.t -> 'a -> Base.Unit.t
Sourceval create : len:Base.Int.t -> 'a -> ('a, [< _ Perms.Export.perms ]) t
Sourceval create_local : len:Base.Int.t -> 'a -> ('a, [< _ Perms.Export.perms ]) t
Sourceval create_float_uninitialized : len:Base.Int.t -> (Base.Float.t, [< _ Perms.Export.perms ]) t
Sourceval init : Base.Int.t -> f:(Base.Int.t -> 'a) -> ('a, [< _ Perms.Export.perms ]) t
Sourceval make_matrix : dimx:Base.Int.t -> dimy:Base.Int.t -> 'a -> (('a, [< _ Perms.Export.perms ]) t, [< _ Perms.Export.perms ]) t
Sourceval copy_matrix : (('a, [> Perms.Export.read ]) t, [> Perms.Export.read ]) t -> (('a, [< _ Perms.Export.perms ]) t, [< _ Perms.Export.perms ]) t
Sourceval append : ('a, [> Perms.Export.read ]) t -> ('a, [> Perms.Export.read ]) t -> ('a, [< _ Perms.Export.perms ]) t
Sourceval concat : ('a, [> Perms.Export.read ]) t Base.List.t -> ('a, [< _ Perms.Export.perms ]) t
Sourceval copy : ('a, [> Perms.Export.read ]) t -> ('a, [< _ Perms.Export.perms ]) t
Sourceval fill : ('a, [> Perms.Export.write ]) t -> pos:Base.Int.t -> len:Base.Int.t -> 'a -> Base.Unit.t
Sourceval of_list : 'a Base.List.t -> ('a, [< _ Perms.Export.perms ]) t
Sourceval map : ('a, [> Perms.Export.read ]) t -> f:('a -> 'b) -> ('b, [< _ Perms.Export.perms ]) t
Sourceval mapi : ('a, [> Perms.Export.read ]) t -> f:(Base.Int.t -> 'a -> 'b) -> ('b, [< _ Perms.Export.perms ]) t
Sourceval folding_map : ('a, [> Perms.Export.read ]) t -> init:'b -> f:('b -> 'a -> 'b * 'c) -> ('c, [< _ Perms.Export.perms ]) t
Sourceval fold_map : ('a, [> Perms.Export.read ]) t -> init:'b -> f:('b -> 'a -> 'b * 'c) -> 'b * ('c, [< _ Perms.Export.perms ]) t
Sourceval iteri : ('a, [> Perms.Export.read ]) t -> f:(Base.Int.t -> 'a -> Base.Unit.t) -> Base.Unit.t
Sourceval foldi : ('a, [> Perms.Export.read ]) t -> init:'b -> f:(Base.Int.t -> 'b -> 'a -> 'b) -> 'b
Sourceval folding_mapi : ('a, [> Perms.Export.read ]) t -> init:'b -> f:(Base.Int.t -> 'b -> 'a -> 'b * 'c) -> ('c, [< _ Perms.Export.perms ]) t
Sourceval fold_mapi : ('a, [> Perms.Export.read ]) t -> init:'b -> f:(Base.Int.t -> 'b -> 'a -> 'b * 'c) -> 'b * ('c, [< _ Perms.Export.perms ]) t
Sourceval fold_right : ('a, [> Perms.Export.read ]) t -> f:('a -> 'b -> 'b) -> init:'b -> 'b
Sourceval sort : ?pos:Base.Int.t -> ?len:Base.Int.t -> ('a, [> Perms.Export.read_write ]) t -> compare:('a -> 'a -> Base.Int.t) -> Base.Unit.t
Sourceval stable_sort : ('a, [> Perms.Export.read_write ]) t -> compare:('a -> 'a -> Base.Int.t) -> Base.Unit.t
Sourceval is_sorted : ('a, [> Perms.Export.read ]) t -> compare:('a -> 'a -> Base.Int.t) -> Base.Bool.t
Sourceval is_sorted_strictly : ('a, [> Perms.Export.read ]) t -> compare:('a -> 'a -> Base.Int.t) -> Base.Bool.t
Sourceval merge : ('a, [> Perms.Export.read ]) t -> ('a, [> Perms.Export.read ]) t -> compare:('a -> 'a -> Base.Int.t) -> ('a, [< _ Perms.Export.perms ]) t
Sourceval concat_map : ('a, [> Perms.Export.read ]) t -> f:('a -> ('b, [> Perms.Export.read ]) t) -> ('b, [< _ Perms.Export.perms ]) t
Sourceval concat_mapi : ('a, [> Perms.Export.read ]) t -> f:(Base.Int.t -> 'a -> ('b, [> Perms.Export.read ]) t) -> ('b, [< _ Perms.Export.perms ]) t
Sourceval partition_tf : ('a, [> Perms.Export.read ]) t -> f:('a -> Base.Bool.t) -> ('a, [< _ Perms.Export.perms ]) t * ('a, [< _ Perms.Export.perms ]) t
Sourceval 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
Sourceval cartesian_product : ('a, [> Perms.Export.read ]) t -> ('b, [> Perms.Export.read ]) t -> ('a * 'b, [< _ Perms.Export.perms ]) t
Sourceval transpose : (('a, [> Perms.Export.read ]) t, [> Perms.Export.read ]) t -> (('a, [< _ Perms.Export.perms ]) t, [< _ Perms.Export.perms ]) t Base.Option.t
Sourceval transpose_exn : (('a, [> Perms.Export.read ]) t, [> Perms.Export.read ]) t -> (('a, [< _ Perms.Export.perms ]) t, [< _ Perms.Export.perms ]) t
Sourceval normalize : (_, _) t -> Base.Int.t -> Base.Int.t
Sourceval slice : ('a, [> Perms.Export.read ]) t -> Base.Int.t -> Base.Int.t -> ('a, [< _ Perms.Export.perms ]) t
Sourceval nget : ('a, [> Perms.Export.read ]) t -> Base.Int.t -> 'a
Sourceval nset : ('a, [> Perms.Export.write ]) t -> Base.Int.t -> 'a -> Base.Unit.t
Sourceval filter_opt : ('a Base.Option.t, [> Perms.Export.read ]) t -> ('a, [< _ Perms.Export.perms ]) t
Sourceval filter_map : ('a, [> Perms.Export.read ]) t -> f:('a -> 'b Base.Option.t) -> ('b, [< _ Perms.Export.perms ]) t
Sourceval filter_mapi : ('a, [> Perms.Export.read ]) t -> f:(Base.Int.t -> 'a -> 'b Base.Option.t) -> ('b, [< _ Perms.Export.perms ]) t
Sourceval for_alli : ('a, [> Perms.Export.read ]) t -> f:(Base.Int.t -> 'a -> Base.Bool.t) -> Base.Bool.t
Sourceval existsi : ('a, [> Perms.Export.read ]) t -> f:(Base.Int.t -> 'a -> Base.Bool.t) -> Base.Bool.t
Sourceval counti : ('a, [> Perms.Export.read ]) t -> f:(Base.Int.t -> 'a -> Base.Bool.t) -> Base.Int.t
Sourceval iter2_exn : ('a, [> Perms.Export.read ]) t -> ('b, [> Perms.Export.read ]) t -> f:('a -> 'b -> Base.Unit.t) -> Base.Unit.t
Sourceval map2_exn : ('a, [> Perms.Export.read ]) t -> ('b, [> Perms.Export.read ]) t -> f:('a -> 'b -> 'c) -> ('c, [< _ Perms.Export.perms ]) t
Sourceval fold2_exn : ('a, [> Perms.Export.read ]) t -> ('b, [> Perms.Export.read ]) t -> init:'c -> f:('c -> 'a -> 'b -> 'c) -> 'c
Sourceval for_all2_exn : ('a, [> Perms.Export.read ]) t -> ('b, [> Perms.Export.read ]) t -> f:('a -> 'b -> Base.Bool.t) -> Base.Bool.t
Sourceval exists2_exn : ('a, [> Perms.Export.read ]) t -> ('b, [> Perms.Export.read ]) t -> f:('a -> 'b -> Base.Bool.t) -> Base.Bool.t
Sourceval filter : ('a, [> Perms.Export.read ]) t -> f:('a -> Base.Bool.t) -> ('a, [< _ Perms.Export.perms ]) t
Sourceval filteri : ('a, [> Perms.Export.read ]) t -> f:(Base.Int.t -> 'a -> Base.Bool.t) -> ('a, [< _ Perms.Export.perms ]) t
Sourceval rev_inplace : ('a, [> Perms.Export.read_write ]) t -> Base.Unit.t
Sourceval of_list_rev : 'a Base.List.t -> ('a, [< _ Perms.Export.perms ]) t
Sourceval of_list_map : 'a Base.List.t -> f:('a -> 'b) -> ('b, [< _ Perms.Export.perms ]) t
Sourceval of_list_mapi : 'a Base.List.t -> f:(Base.Int.t -> 'a -> 'b) -> ('b, [< _ Perms.Export.perms ]) t
Sourceval of_list_rev_map : 'a Base.List.t -> f:('a -> 'b) -> ('b, [< _ Perms.Export.perms ]) t
Sourceval of_list_rev_mapi : 'a Base.List.t -> f:(Base.Int.t -> 'a -> 'b) -> ('b, [< _ Perms.Export.perms ]) t
Sourceval map_inplace : ('a, [> Perms.Export.read_write ]) t -> f:('a -> 'a) -> Base.Unit.t
Sourceval find_exn : ('a, [> Perms.Export.read ]) t -> f:('a -> Base.Bool.t) -> 'a
Sourceval find_map_exn : ('a, [> Perms.Export.read ]) t -> f:('a -> 'b Base.Option.t) -> 'b
Sourceval findi : ('a, [> Perms.Export.read ]) t -> f:(Base.Int.t -> 'a -> Base.Bool.t) -> (Base.Int.t * 'a) Base.Option.t
Sourceval findi_exn : ('a, [> Perms.Export.read ]) t -> f:(Base.Int.t -> 'a -> Base.Bool.t) -> Base.Int.t * 'a
Sourceval find_mapi : ('a, [> Perms.Export.read ]) t -> f:(Base.Int.t -> 'a -> 'b Base.Option.t) -> 'b Base.Option.t
Sourceval find_mapi_exn : ('a, [> Perms.Export.read ]) t -> f:(Base.Int.t -> 'a -> 'b Base.Option.t) -> 'b
Sourceval find_consecutive_duplicate : ('a, [> Perms.Export.read ]) t -> equal:('a -> 'a -> Base.Bool.t) -> ('a * 'a) Base.Option.t
Sourceval reduce : ('a, [> Perms.Export.read ]) t -> f:('a -> 'a -> 'a) -> 'a Base.Option.t
Sourceval reduce_exn : ('a, [> Perms.Export.read ]) t -> f:('a -> 'a -> 'a) -> 'a
Sourceval permute : ?random_state:Base.Random.State.t -> ?pos:Base.Int.t -> ?len:Base.Int.t -> ('a, [> Perms.Export.read_write ]) t -> Base.Unit.t
Sourceval zip : ('a, [> Perms.Export.read ]) t -> ('b, [> Perms.Export.read ]) t -> ('a * 'b, [< _ Perms.Export.perms ]) t Base.Option.t
Sourceval zip_exn : ('a, [> Perms.Export.read ]) t -> ('b, [> Perms.Export.read ]) t -> ('a * 'b, [< _ Perms.Export.perms ]) t
Sourceval unzip : ('a * 'b, [> Perms.Export.read ]) t -> ('a, [< _ Perms.Export.perms ]) t * ('b, [< _ Perms.Export.perms ]) t
Sourceval sorted_copy : ('a, [> Perms.Export.read ]) t -> compare:('a -> 'a -> Base.Int.t) -> ('a, [< _ Perms.Export.perms ]) t
Sourceval last : ('a, [> Perms.Export.read ]) t -> 'a
Sourceval equal : ('a -> 'a -> Base.Bool.t) -> ('a, [> Perms.Export.read ]) t -> ('a, [> Perms.Export.read ]) t -> Base.Bool.t
Sourceval to_sequence : ('a, [> Perms.Export.read ]) t -> 'a Sequence.t
Sourceval to_sequence_mutable : ('a, [> Perms.Export.read ]) t -> 'a Sequence.t
OCaml

Innovation. Community. Security.