Module ReactiveData.RList
Reactive list data structure
type 'a p = | I of int * 'a(*
*)I (i, v)addsvat positioni| R of int(*
*)R iremovesi-th element| U of int * 'a(*
*)U (i, v)substitutesi-th element withv| X of int * int(*
*)X (i, j)swaps thei-th andj-th elements
Patch operation on lists. All operations are of linear complexity.
type 'a patch = 'a p listA patch is a list of patch operations. The operations are applied in the order they appear in the list.
The indices correspond to list contents after the operations that appear earlier in the list have been applied, not to the contents before the whole patch operation.
A patch comprised of I, R, and U steps with increasing indices can be applied in time O(m + n), where m is the patch length and n is the current size of the list. (Arbitrary patches are slower, requiring O(m * n).)
include S with type 'a data = 'a list and type 'a patch := 'a patch
type 'a tReactive version of the data container
type 'a data = 'a listRaw (non-reactive) version of the data container
type 'a msg = Message format
type 'a handleHandle that permits applying incremental updates
val empty : 'a tEmpty data structure
Build a container from initial contents. The handle can be used for performing reactive updates.
from_event d e is a container whose initial value is d, and which gets updated for every occurrence of e
Convert a React signal into a ReactiveData container.
Whenever the signal changes from value v to value v', we detect the differences between v and v', and perform downstream computation (e.g., for map) only on the new and modified elements.
set h d sets the contents of the container corresponding to h, disregarding previous contents
map f c applies f on all elements of c, producing a new reactive container c'. Modifying the contents of c leads to modifications of c'. f is applied only on the new or modified elements of c.
fold f c v accumulates the updates on c with f starting from v.
The result is a signal of value f m_n (f ... (f m_1 v)), where m_1 ... m_n are the messages that have been applied since the beginning of fold. m_1 is a pseudo-message Set l, accounting for the contents l of c at the time when accumulation starts.
val cons : 'a -> 'a handle -> unitAdd element to the beginning
val snoc : 'a -> 'a handle -> unitAdd element to the end
val insert : 'a -> int -> 'a handle -> unitinsert v i h adds v as the i-th position in the container corresponding to h. The indices of the subsequent elements change.
val remove : int -> 'a handle -> unitremove i h removes the i-th position from the container corresponding to h. The indices of the subsequent elements change.
remove_eq l x removes the first occurence of x from l
val update : 'a -> int -> 'a handle -> unitupdate v i h substitutes the i-th element of the container corresponding to h with v
update_eq l a b substitutes the first occurence of a (according to eq) in l with b
val move : int -> int -> 'a handle -> unitmove i offset h moves the i-th element of the container corresponding by offset positions in h, modifying the indices of other elements
val singleton : 'a -> 'a tProduce container list containing a single, constant element
val singleton_s : 'a React.S.t -> 'a tProduce reactive list containing a single element that gets updated based on a signal
concat a b is the concatenation of a and b, and it gets updated whenever a and b change
filter pred l keeps the elements of l matching pred; gets updated when l is. pred should be a pure function
val for_all : ('a -> bool) -> 'a t -> bool React.S.tfor_all fn l is a bool React.S.t verifying that all elements x of l satisfy fn x