Module ReactiveData.RList

module RList: sig .. end
Reactive list data structure

type 'a p = 
| I of int * 'a (*
I (i, v) adds v at position i
*)
| R of int (*
R i removes i-th element
*)
| U of int * 'a (*
U (i, v) substitutes i-th element with v
*)
| X of int * int (*
X (i, j) swaps the i-th and j-th elements
*)
Patch operation on lists. All operations are of linear complexity.
type 'a patch = 'a p list 
A 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 ReactiveData.S
val cons : 'a -> 'a handle -> unit
Add element to the beginning
val snoc : 'a -> 'a handle -> unit
Add element to the end
val insert : 'a -> int -> 'a handle -> unit
insert 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 -> unit
remove i h removes the i-th position from the container corresponding to h. The indices of the subsequent elements change.
val update : 'a -> int -> 'a handle -> unit
update v i h substitutes the i-th element of the container corresponding to h with v
val move : int -> int -> 'a handle -> unit
move i j h moves the i-th element of the container corresponding to h to the j-th position, modifying the indices of other elements
val singleton : 'a -> 'a t
Produce container list containing a single, constant element
val singleton_s : 'a React.S.t -> 'a t
Produce reactive list containing a single element that gets updated based on a signal
val concat : 'a t -> 'a t -> 'a t
concat a b is the concatenation of a and b, and it gets updated whenever a and b change
val rev : 'a t -> 'a t
rev a is the reversal of a; rev a gets updated along with a