PieceTable

PieceTable a

Represents a Piece table which is typically used to represent a text document while it is edited in a text editor

Entry

Represents an index into the original or add buffer

insert : PieceTable a, { values : List a, index : U64 } -> PieceTable a

Insert values into the table at a given index.

If index is larger than current buffer, appends to end of file.

length : List Entry -> U64

Calculate the total length when buffer indexes will be converted to a list

delete : PieceTable a, { index : U64 } -> PieceTable a

Delete the value at index

If index is out of range this has no effect.

toList : PieceTable a -> List a

Fuse the original and added buffers into a single list