From 142643bfa44a8122fcffd4e3c1cde5ec7c512067 Mon Sep 17 00:00:00 2001 From: Alex Ionescu Date: Thu, 18 Jan 2024 21:06:53 +0100 Subject: [PATCH] Rebuild docs --- .gitignore | 8 +------- copy-docs.sh => build-docs.sh | 3 +++ docs/docs/vec/Vec/Infix/index.html | 2 +- docs/docs/vec/Vec/Let_syntax/index.html | 2 -- docs/docs/vec/Vec/index.html | 4 ++-- 5 files changed, 7 insertions(+), 12 deletions(-) rename copy-docs.sh => build-docs.sh (73%) delete mode 100644 docs/docs/vec/Vec/Let_syntax/index.html diff --git a/.gitignore b/.gitignore index 11ac87f..e35d885 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1 @@ -_build/ -*/.merlin -*.cmi -*.cmx -*.o -*.out -.vscode/ +_build diff --git a/copy-docs.sh b/build-docs.sh similarity index 73% rename from copy-docs.sh rename to build-docs.sh index 9083785..5e474bf 100755 --- a/copy-docs.sh +++ b/build-docs.sh @@ -1,3 +1,6 @@ #!/bin/sh +set -eu + +dune build @doc rm -rf docs/docs cp -a _build/default/_doc/_html/. docs/docs diff --git a/docs/docs/vec/Vec/Infix/index.html b/docs/docs/vec/Vec/Infix/index.html index 25d7c54..0a55f62 100644 --- a/docs/docs/vec/Vec/Infix/index.html +++ b/docs/docs/vec/Vec/Infix/index.html @@ -1,2 +1,2 @@ -Infix (vec.Vec.Infix)

Module Vec.Infix

Contains infix versions of some vector operations.

val (.![]) : ('a, [> `R ]) t -> int -> 'a

Infix version of get_exn.

val (.![]<-) : ('a, [> `W ]) t -> int -> 'a -> unit

Infix version of set_exn.

val (.?[]) : ('a, [> `R ]) t -> int -> 'a option

Infix version of get.

val (.?[]<-) : ('a, [> `W ]) t -> int -> 'a -> bool

Infix version of set.

val (@) : ('a, [> `R ]) t -> ('a, [> `R ]) t -> ('a, [ `R | `W ]) t

Infix version of append.

val (=|<) : ('a -> 'b) -> ('a, [> `R ]) t -> ('b, [ `R | `W ]) t

Infix version of map.

val (>|=) : ('a, [> `R ]) t -> ('a -> 'b) -> ('b, [ `R | `W ]) t

Infix version of map, with the arguments flipped.

val (<$>) : ('a -> 'b) -> ('a, [> `R ]) t -> ('b, [ `R | `W ]) t

Infix version of map.

val (<*>) : ('a -> 'b, [> `R ]) t -> ('a, [> `R ]) t -> ('b, [ `R | `W ]) t

Infix version of apply.

val (=<<) : ('a -> ('b, [> `R ]) t) -> ('a, [> `R ]) t -> ('b, [ `R | `W ]) t

Infix version of flat_map.

val (>>=) : ('a, [> `R ]) t -> ('a -> ('b, [> `R ]) t) -> ('b, [ `R | `W ]) t

Infix version of flat_map, with the arguments flipped.

val (--) : int -> int -> (int, [ `R | `W ]) t

Infix version of range.

+Infix (vec.Vec.Infix)

Module Vec.Infix

Contains infix versions of some vector operations, as well as binding operators and extended indexing operators.

val (.![]) : ('a, [> `R ]) t -> int -> 'a

Infix version of get.

val (.?[]) : ('a, [> `R ]) t -> int -> 'a option

Infix version of try_get.

val (.![]<-) : ('a, [> `W ]) t -> int -> 'a -> unit

Infix version of set.

val (.?[]<-) : ('a, [> `W ]) t -> int -> 'a -> bool

Infix version of try_set.

val let+ : ('a, [> `R ]) t -> ('a -> 'b) -> ('b, [ `R | `W ]) t

Equivalent to map, but with the arguments flipped.

val and+ : ('a, [> `R ]) t -> ('b, [> `R ]) t -> ('a * 'b, [ `R | `W ]) t

Equivalent to cartesian_product.

val let* : ('a, [> `R ]) t -> ('a -> ('b, [> `R ]) t) -> ('b, [ `R | `W ]) t

Equivalent to flat_map, but with the arguments flipped.

val and* : ('a, [> `R ]) t -> ('b, [> `R ]) t -> ('a * 'b, [ `R | `W ]) t

Equivalent to cartesian_product.

val (@) : ('a, [> `R ]) t -> ('a, [> `R ]) t -> ('a, [ `R | `W ]) t

Infix version of append.

val (=|<) : ('a -> 'b) -> ('a, [> `R ]) t -> ('b, [ `R | `W ]) t

Infix version of map.

val (>|=) : ('a, [> `R ]) t -> ('a -> 'b) -> ('b, [ `R | `W ]) t

Infix version of map, with the arguments flipped.

val (<$>) : ('a -> 'b) -> ('a, [> `R ]) t -> ('b, [ `R | `W ]) t

Infix version of map.

val (<*>) : ('a -> 'b, [> `R ]) t -> ('a, [> `R ]) t -> ('b, [ `R | `W ]) t

Infix version of apply.

val (=<<) : ('a -> ('b, [> `R ]) t) -> ('a, [> `R ]) t -> ('b, [ `R | `W ]) t

Infix version of flat_map.

val (>>=) : ('a, [> `R ]) t -> ('a -> ('b, [> `R ]) t) -> ('b, [ `R | `W ]) t

Infix version of flat_map, with the arguments flipped.

val (--) : int -> int -> (int, [ `R | `W ]) t

Infix version of range.

diff --git a/docs/docs/vec/Vec/Let_syntax/index.html b/docs/docs/vec/Vec/Let_syntax/index.html deleted file mode 100644 index 9612dac..0000000 --- a/docs/docs/vec/Vec/Let_syntax/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -Let_syntax (vec.Vec.Let_syntax)

Module Vec.Let_syntax

Provides support for OCaml 4.08's binding operator syntax.

val let+ : ('a, [> `R ]) t -> ('a -> 'b) -> ('b, [ `R | `W ]) t

Equivalent to map, but with the arguments flipped.

val and+ : ('a, [> `R ]) t -> ('b, [> `R ]) t -> ('a * 'b, [ `R | `W ]) t

Equivalent to cartesian_product.

val let* : ('a, [> `R ]) t -> ('a -> ('b, [> `R ]) t) -> ('b, [ `R | `W ]) t

Equivalent to flat_map, but with the arguments flipped.

val and* : ('a, [> `R ]) t -> ('b, [> `R ]) t -> ('a * 'b, [ `R | `W ]) t

Equivalent to cartesian_product.

diff --git a/docs/docs/vec/Vec/index.html b/docs/docs/vec/Vec/index.html index 4405078..592c5b8 100644 --- a/docs/docs/vec/Vec/index.html +++ b/docs/docs/vec/Vec/index.html @@ -1,5 +1,5 @@ -Vec (vec.Vec)

Module Vec

Mutable dynamic arrays

type ('a, -'p) t

The 'p type parameter is a phantom type parameter that represents the vector's mutability.

It is [`R | `W] for read-write vectors, [`R] for read-only vectors, or [`W] for write-only vectors.

val default_growth_rate : float

The default growth rate of newly-created vectors.

Creating vectors

val make : ?growth_rate:float -> ?capacity:int -> unit -> ('a, [ `R | `W ]) t

Constructs a vector with the specified growth rate and capacity.

Growth rate defaults to default_growth_rate.

Capacity defaults to 0.

val range : int -> int -> (int, [ `R | `W ]) t

Constructs a vector containing all numbers in the specified range.

val singleton : 'a -> ('a, [ `R | `W ]) t

Returns a singleton vector containing the specified item. (Applicative functor pure operation)

val copy : ('a, [> `R ]) t -> ('a, [ `R | `W ]) t

Creates a copy of the vector.

Restricting permissions

val as_read_only : ('a, [> `R ]) t -> ('a, [ `R ]) t

Reinterprets the vector as a read-only vector.

val as_write_only : ('a, [> `W ]) t -> ('a, [ `W ]) t

Reinterprets the vector as a write-only vector.

Basic properties

val length : ('a, [> ]) t -> int

Returns the length of the vector.

val capacity : ('a, [> ]) t -> int

Returns the capacity of the vector.

val ensure_capacity : int -> ('a, [> `W ]) t -> unit

Ensures the vector's buffer has at least as many free slots as the specified value.

val growth_rate : ('a, [> ]) t -> float

Returns the growth rate of the vector.

val set_growth_rate : float -> ('a, [> `W ]) t -> unit

Sets the growth rate of vector to the specified value.

val ensure_growth_rate : float -> ('a, [> `W ]) t -> unit

Ensures the vector's growth rate is at least as great as the specified value.

Accessing elements

val get : ('a, [> `R ]) t -> int -> 'a option

Gets the value in the vector at the specified index. Returns None if the index is out of range.

val set : ('a, [> `W ]) t -> int -> 'a -> bool

Sets the value in the vector at the specified index to the specified value. Returns false if the index is out of range.

val get_exn : ('a, [> `R ]) t -> int -> 'a

Gets the value in the vector at the specified index.

  • raises Invalid_argument

    if the index is out of bounds.

val set_exn : ('a, [> `W ]) t -> int -> 'a -> unit

Sets the value in the vector at the specified index to the specified value.

  • raises Invalid_argument

    if the index is out of bounds.

val find : ('a -> bool) -> ('a, [> `W ]) t -> 'a option

Returns the first element of the vector that satisfies the predicate, or None.

val find_exn : ('a -> bool) -> ('a, [> `W ]) t -> 'a

Returns the first element of the vector that satisfies the predicate.

  • raises Not_found

    if no element satisfies the predicate.

Conversions

val of_list : 'a list -> ('a, [ `R | `W ]) t

Constructs a vector from the specified list.

val to_list : ('a, [> `R ]) t -> 'a list

Constructs a list from the specified vector.

val of_array : 'a array -> ('a, [ `R | `W ]) t

Constructs a vector from the specified array.

val to_array : ('a, [> `R ]) t -> 'a array

Constructs an array from the specified vector.

val pretty_print : ('a -> string) -> ('a, [> `R ]) t -> string

Returns a string representation of the vector, using the specified function to format each value.

Modifying vectors

val clear : ('a, [> `W ]) t -> unit

Resets the vector to an empty state.

val shrink_to_fit : ('a, [> `W ]) t -> unit

Shrinks the vector's internal buffer to only be as large as the vector's length.

val push : 'a -> ('a, [> `W ]) t -> unit

Pushes the specified item onto the end of the vector.

val pop : ('a, [ `R | `W ]) t -> 'a option

Pops off the item from the end of the vector.

val add_at : int -> 'a -> ('a, [> `W ]) t -> bool

Inserts an item into the vector at the specified index.

val remove_at : int -> ('a, [ `R | `W ]) t -> 'a option

Removes and returns the item at the specified index.

val drop_at : int -> ('a, [> `W ]) t -> bool

Removes the item at the specified index, without returning it.

Transformations

val map : ('a -> 'b) -> ('a, [> `R ]) t -> ('b, [ `R | `W ]) t

Maps the specified function over the vector, returning a new vector. (Functor map operation)

val mapi : (int -> 'a -> 'b) -> ('a, [> `R ]) t -> ('b, [ `R | `W ]) t

Like map, but the function also takes the item's index as a parameter.

val map_in_place : ('a -> 'a) -> ('a, [ `R | `W ]) t -> unit

Like map, but the transformation is done in-place.

val flat_map : +Vec (vec.Vec)

Module Vec

Mutable dynamic arrays

type ('a, -'p) t

A value of type ('a, 'p) Vec.t is a vector of values of type 'a, with mutability permissions 'p.

The permissions can be [`R | `W] for read-write vectors, [`R] for read-only vectors, or [`W] for write-only vectors.

Reading vector properties

val length : ('a, [> ]) t -> int

Returns the length of the vector.

val capacity : ('a, [> ]) t -> int

Returns the capacity of the vector.

Creating vectors

val make : ?capacity:int -> unit -> ('a, [ `R | `W ]) t

Constructs a vector with the specified capacity (defaults to 0).

val range : int -> int -> (int, [ `R | `W ]) t

Constructs a vector containing all numbers in the specified range. Both ascending and descending ranges are supported.

val singleton : 'a -> ('a, [ `R | `W ]) t

Returns a singleton vector containing the specified item. (Applicative functor pure operation)

val copy : ('a, [> `R ]) t -> ('a, [ `R | `W ]) t

Creates a copy of the vector.

Restricting permissions

val as_read_only : ('a, [> `R ]) t -> ('a, [ `R ]) t

Reinterprets the vector as a read-only vector.

val as_write_only : ('a, [> `W ]) t -> ('a, [ `W ]) t

Reinterprets the vector as a write-only vector.

Accessing elements

val get : ('a, [> `R ]) t -> int -> 'a

Gets the value in the vector at the specified index.

  • raises [Invalid_argument]

    if the index is out of bounds.

val try_get : ('a, [> `R ]) t -> int -> 'a option

Gets the value in the vector at the specified index. Returns None if the index is out of range.

val set : ('a, [> `W ]) t -> int -> 'a -> unit

Sets the value in the vector at the specified index to the specified value.

  • raises [Invalid_argument]

    if the index is out of bounds.

val try_set : ('a, [> `W ]) t -> int -> 'a -> bool

Sets the value in the vector at the specified index to the specified value. Returns false if the index is out of range.

val find : ('a -> bool) -> ('a, [> `W ]) t -> 'a

Returns the first element of the vector that satisfies the predicate.

  • raises [Not_found]

    if no element satisfies the predicate.

val try_find : ('a -> bool) -> ('a, [> `W ]) t -> 'a option

Returns the first element of the vector that satisfies the predicate, or None.

Conversions

val of_list : 'a list -> ('a, [ `R | `W ]) t

Constructs a vector from the specified list.

val to_list : ('a, [> `R ]) t -> 'a list

Constructs a list from the specified vector.

val of_array : 'a array -> ('a, [ `R | `W ]) t

Constructs a vector from a copy of the specified array.

val to_array : ('a, [> `R ]) t -> 'a array

Constructs an array containing the values of specified vector.

val of_array_unsafe : 'a array -> ('a, [ `R | `W ]) t

Constructs a vector from the specified array, without copying.

val to_array_unsafe : ('a, [ `R | `W ]) t -> 'a array

Returns the vector's underlying buffer. Note: The array may contain uninitialized elements.

val pretty_print : ('a -> string) -> ('a, [> `R ]) t -> string

Returns a string representation of the vector, using the specified function to format each value.

Modifying vectors

val clear : ('a, [> `W ]) t -> unit

Resets the vector to an empty state.

val reserve : int -> ('a, [> `W ]) t -> unit

Ensures the vector's capacity is at least as large as the specified value, allocating if necessary.

val shrink_to_fit : ('a, [> `W ]) t -> unit

Shrinks the vector's internal buffer to only be as large as the vector's length.

val push : 'a -> ('a, [> `W ]) t -> unit

Pushes the specified item onto the end of the vector.

val pop : ('a, [ `R | `W ]) t -> 'a

Pops off the item from the end of the vector.

  • raises [Invalid_argument]

    if the vector is empty.

val try_pop : ('a, [ `R | `W ]) t -> 'a option

Pops off the item from the end of the vector. Returns None if the vector is empty.

val insert_at : int -> 'a -> ('a, [> `W ]) t -> unit

Inserts an item into the vector at the specified index.

  • raises [Invalid_argument]

    if the index is out of bounds.

val try_insert_at : int -> 'a -> ('a, [> `W ]) t -> bool

Inserts an item into the vector at the specified index. Returns false if the index is out of range.

val remove_at : int -> ('a, [ `R | `W ]) t -> 'a

Removes and returns the item at the specified index.

  • raises [Invalid_argument]

    if the index is out of bounds.

val try_remove_at : int -> ('a, [ `R | `W ]) t -> 'a option

Removes and returns the item at the specified index. Returns None if the index is out of range.

Transformations

val map : ('a -> 'b) -> ('a, [> `R ]) t -> ('b, [ `R | `W ]) t

Maps the specified function over the vector, returning a new vector. (Functor map operation)

val mapi : (int -> 'a -> 'b) -> ('a, [> `R ]) t -> ('b, [ `R | `W ]) t

Like map, but the function also takes the item's index as a parameter.

val map_in_place : ('a -> 'a) -> ('a, [ `R | `W ]) t -> unit

Like map, but the transformation is done in-place.

val flat_map : ('a -> ('b, [> `R ]) t) -> ('a, [> `R ]) t -> ('b, [ `R | `W ]) t

Like map, but flattens the result. (Monad bind operation)

val rev : ('a, [> `R ]) t -> ('a, [ `R | `W ]) t

Returns a new vector that contains all the items in the specified vector, but in reverse order.

val rev_in_place : ('a, [ `R | `W ]) t -> unit

Reverses the vector in-place.

Filters & folds

val filter : ('a -> bool) -> ('a, [> `R ]) t -> ('a, [ `R | `W ]) t

Returns a new vector containing only the items from the first vector that satisfy the specified predicate.

val filteri : (int -> 'a -> bool) -> ('a, [> `R ]) t -> ('a, [ `R | `W ]) t

Like filter, but the predicate also takes the item's index as a parameter.

val filter_in_place : ('a -> bool) -> ('a, [ `R | `W ]) t -> unit

Performs a filter in-place, based on the specified predicate.

val fold_left : ('b -> 'a -> 'b) -> 'b -> ('a, [> `R ]) t -> 'b

Folds the specified function and default value over the array, from left to right.

val fold_right : ('a -> 'b -> 'b) -> ('a, [> `R ]) t -> 'b -> 'b

Folds the specified function and default value over the array, from right to left.

Combining vectors

val append : ('a, [> `R ]) t -> ('a, [> `R ]) t -> ('a, [ `R | `W ]) t

Concatenates the two vectors into a new vector.

val append_in_place : ('a, [ `R | `W ]) t -> ('a, [> `R ]) t -> unit

Appends the second vector to the first vector in-place.

val cartesian_product : @@ -13,4 +13,4 @@ ('a -> 'b -> 'c) -> ('a, [> `R ]) t -> ('b, [> `R ]) t -> - ('c, [ `R | `W ]) t

Zips the two vectors together, using the specified function to combine values.

Querying vectors

val exists : ('a -> bool) -> ('a, [> `R ]) t -> bool

Returns true if any item in the vector satisfies the specified predicate.

val for_all : ('a -> bool) -> ('a, [> `R ]) t -> bool

Returns true if all items in the vector satisfy the specified predicate.

val mem : 'a -> ('a, [> `R ]) t -> bool

Returns true if the specified item exists in the vector. Uses structural equality.

val memq : 'a -> ('a, [> `R ]) t -> bool

Returns true if the specified item exists in the vector. Uses physical equality.

Sorting

val sort : ('a, [ `R | `W ]) t -> unit

Sorts the vector.

val sort_by : ('a -> 'a -> int) -> ('a, [ `R | `W ]) t -> unit

Sorts the vector using the specified comparison function.

Equality and comparison

val equal : ('a, [> `R ]) t -> ('a, [> `R ]) t -> bool

Compares two vectors for equality.

val equal_by : ('a -> 'a -> bool) -> ('a, [> `R ]) t -> ('a, [> `R ]) t -> bool

Compares two vectors for equality, using the specified equality function for elements.

val compare : ('a, [> `R ]) t -> ('a, [> `R ]) t -> int

Compares two vectors lexicographically.

val compare_by : ('a -> 'a -> int) -> ('a, [> `R ]) t -> ('a, [> `R ]) t -> int

Compares two vectors lexicographically, using the specified comparison function for elements.

Iteration

val iter : ('a -> unit) -> ('a, [> `R ]) t -> unit

Applies the specified function to each item in the vector.

val iteri : (int -> 'a -> unit) -> ('a, [> `R ]) t -> unit

Like iter, but the function also takes the item's index as a parameter.

Infix operators

module Infix : sig ... end

Contains infix versions of some vector operations.

Monadic syntax

module Let_syntax : sig ... end

Provides support for OCaml 4.08's binding operator syntax.

+ ('c, [ `R | `W ]) t

Zips the two vectors together, using the specified function to combine values.

Querying vectors

val exists : ('a -> bool) -> ('a, [> `R ]) t -> bool

Returns true if any item in the vector satisfies the specified predicate.

val for_all : ('a -> bool) -> ('a, [> `R ]) t -> bool

Returns true if all items in the vector satisfy the specified predicate.

val mem : 'a -> ('a, [> `R ]) t -> bool

Returns true if the specified item exists in the vector. Uses structural equality.

val memq : 'a -> ('a, [> `R ]) t -> bool

Returns true if the specified item exists in the vector. Uses physical equality.

Sorting

val sort : ('a, [ `R | `W ]) t -> unit

Sorts the vector in-place.

val sort_by : ('a -> 'a -> int) -> ('a, [ `R | `W ]) t -> unit

Sorts the vector in-place, using the specified comparison function.

Equality and comparison

val equal : ('a, [> `R ]) t -> ('a, [> `R ]) t -> bool

Compares two vectors for equality.

val equal_by : ('a -> 'a -> bool) -> ('a, [> `R ]) t -> ('a, [> `R ]) t -> bool

Compares two vectors for equality, using the specified equality function for elements.

val compare : ('a, [> `R ]) t -> ('a, [> `R ]) t -> int

Compares two vectors lexicographically.

val compare_by : ('a -> 'a -> int) -> ('a, [> `R ]) t -> ('a, [> `R ]) t -> int

Compares two vectors lexicographically, using the specified comparison function for elements.

Iteration

val iter : ('a -> unit) -> ('a, [> `R ]) t -> unit

Applies the specified function to each item in the vector.

val iteri : (int -> 'a -> unit) -> ('a, [> `R ]) t -> unit

Like iter, but the function also takes the item's index as a parameter.

Infix operators

module Infix : sig ... end

Contains infix versions of some vector operations, as well as binding operators and extended indexing operators.