package lwd

  1. Overview
  2. Docs
Lightweight reactive documents

Install

Dune Dependency

Authors

Maintainers

Sources

lwd-0.4.tbz
sha256=9e7165b650567cf39eac5e07b95346cd7719c5149db0cf9a6de0f965d43ec7c5
sha512=7e015ecbdf19dbf503e70fb1fb8f6e2f78182cafbda172d9849a910d92c4a44e0c4d0fe8fb7a81515ba224ce9e624fac79ef41ad04a010af460dc2c0c2f261bc

doc/lwd/Lwd_table/index.html

Module Lwd_tableSource

Table manipulation

Lwd_table is an ordered collection with an impure interface. It is designed to be efficient in an interactive setting.

The interface mimics the one of a doubly-linked lists: from a node, called row, you can iterate backward and forward, insert and delete other nodes, and change the value it is bound to.

The sequence of nodes can be observed by map/reduce operations, that will be recomputed efficiently when sequence changes.

Sourcetype 'a t
Sourcetype 'a row

The type of tables

Sourceval make : unit -> 'a t

Create a new table

Inserting rows

Sourceval prepend : ?set:'a -> 'a t -> 'a row

Insert and return a new row at the start of a table. It can be optionnally initialized to the value of set.

Sourceval append : ?set:'a -> 'a t -> 'a row

Insert and return a new row at the end of a table. It can be optionnally initialized to the value of set.

Sourceval prepend' : 'a t -> 'a -> unit
Sourceval append' : 'a t -> 'a -> unit
Sourceval before : ?set:'a -> 'a row -> 'a row

Insert and return a new row just before an existing row. It can be optionnally initialized to the value of set.

If the input row is unbound (is_bound returns false), the returned row is too.

Sourceval after : ?set:'a -> 'a row -> 'a row

Insert and return a new row just after an existing row. It can be optionnally initialized to the value of set.

If the input row is unbound (is_bound returns false), the returned row is too.

Iterating over rows

Sourceval first : 'a t -> 'a row option

Returns the first row of a table, or None if the table is empty

Sourceval last : 'a t -> 'a row option

Returns the last row of a table, or None if the table is empty

Sourceval next : 'a row -> 'a row option

Returns the row next to another one, or None if the input row is unbound or is the last row

Sourceval prev : 'a row -> 'a row option

Returns the row just before another one, or None if the input row is unbound or is the first row

Accessing and changing row contents

Sourceval get : 'a row -> 'a option

Get the value associated with a row, if any, or None if the row is unbound

Sourceval set : 'a row -> 'a -> unit

Set the value associated with a row, or do nothing if the row is unbound

Sourceval unset : 'a row -> unit

Unset the value associated with a row

Removing rows

Sourceval is_bound : 'a row -> bool

Returns true iff the row is bound in a table (it has not beem removed yet, the table has not been cleared)

Sourceval remove : 'a row -> unit

remove a row from its table, is_bound will be true after that

Sourceval clear : 'a t -> unit

Remove all rows from a table

Observing table contents

Sourceval reduce : 'a Lwd_utils.monoid -> 'a t -> 'a Lwd.t

Observe the content of a table by reducing it with a monoid

Sourceval map_reduce : ('a row -> 'a -> 'b) -> 'b Lwd_utils.monoid -> 'a t -> 'b Lwd.t

Observe the content of a table by mapping and reducing it

Sourceval iter : ('a -> unit) -> 'a t -> unit

Immediate, non reactive, iteration over elements of a table

OCaml

Innovation. Community. Security.