Port of Haskell pointedlist library
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src/Data/List
test
.gitignore
AUTHORS
LICENSE
README.md
bower.json
package.json

README.md

purescript-pointed-list

Port of Haskell pointedlist library.

Type

Single type provided by this library is Data.List.Pointed:

newtype Pointed a = Pointed
  { focus  a
  , reversedPrefix  List a
  , suffix  List a
  }

It allows to quickly move focus and update or replace value at the current position.

Operations

Currently this library provides bunch of instances: Foldable, Foldable1, Traversable, Functor, Comonad. If you want to extend this set please don't hesitate to open a PR.

Additionally it implements following operations:

  • prev, next, insertLeft, insertRight, deleteLeft, deleteRight, moveLeft, moveRight, replace, dropPrefix, dropSuffix, atStart, atEnd - O(1)
  • first, last - O(n)

Usage example

Pointed list structure can be useful for example when you are implementing history browsing with undo / redo operations.