Module

Data.FingerTree

Package
purescript-sequences
Repository
hdgarrood/purescript-sequences

This module defines a general-purpose data structure, known as a "finger tree", which is intended to be used as a building block for implementing other data structures. See, for example, Seq from Data.Sequence.

#Node Source

data Node v a

Constructors

Instances

#node2 Source

node2 :: forall a v. Monoid v => Measured a v => a -> a -> Node v a

#node3 Source

node3 :: forall a v. Monoid v => Measured a v => a -> a -> a -> Node v a

#nodeToDigit Source

nodeToDigit :: forall a v. Node v a -> Digit a

#FingerTree Source

data FingerTree v a

Constructors

Instances

#lazyEmpty Source

lazyEmpty :: forall v a. Lazy (FingerTree v a)

#deep Source

deep :: forall a v. Monoid v => Measured a v => Digit a -> Lazy (FingerTree v (Node v a)) -> Digit a -> FingerTree v a

#eqFingerTree Source

eqFingerTree :: forall a v. Monoid v => Measured a v => Eq a => FingerTree v a -> FingerTree v a -> Boolean

#compareFingerTree Source

compareFingerTree :: forall a v. Monoid v => Measured a v => Ord a => FingerTree v a -> FingerTree v a -> Ordering

#cons Source

cons :: forall a v. Monoid v => Measured a v => a -> FingerTree v a -> FingerTree v a

#snoc Source

snoc :: forall a v. Monoid v => Measured a v => FingerTree v a -> a -> FingerTree v a

#consAll Source

consAll :: forall f a v. Monoid v => Measured a v => Foldable f => f a -> FingerTree v a -> FingerTree v a

#snocAll Source

snocAll :: forall f a v. Monoid v => Measured a v => Foldable f => FingerTree v a -> f a -> FingerTree v a

#toFingerTree Source

toFingerTree :: forall f a v. Monoid v => Measured a v => Foldable f => f a -> FingerTree v a

#ViewL Source

data ViewL s a

Constructors

Instances

#viewL Source

viewL :: forall a v. Monoid v => Measured a v => FingerTree v a -> ViewL (FingerTree v) a

#deepL Source

deepL :: forall a v. Monoid v => Measured a v => Array a -> Lazy (FingerTree v (Node v a)) -> Digit a -> FingerTree v a

#isEmpty Source

isEmpty :: forall a v. Monoid v => Measured a v => FingerTree v a -> Boolean

#head Source

head :: forall a v. Monoid v => Measured a v => FingerTree v a -> Maybe a

#tail Source

tail :: forall a v. Monoid v => Measured a v => FingerTree v a -> Maybe (FingerTree v a)

#ViewR Source

data ViewR s a

Constructors

#viewR Source

viewR :: forall a v. Monoid v => Measured a v => FingerTree v a -> ViewR (FingerTree v) a

#deepR Source

deepR :: forall a v. Monoid v => Measured a v => Digit a -> Lazy (FingerTree v (Node v a)) -> Array a -> FingerTree v a

#last Source

last :: forall a v. Monoid v => Measured a v => FingerTree v a -> Maybe a

#init Source

init :: forall a v. Monoid v => Measured a v => FingerTree v a -> Maybe (FingerTree v a)

#app3 Source

app3 :: forall a v. Monoid v => Measured a v => FingerTree v a -> Array a -> FingerTree v a -> FingerTree v a

#nodes Source

nodes :: forall a v. Monoid v => Measured a v => Array a -> Array (Node v a)

#append Source

append :: forall a v. Monoid v => Measured a v => FingerTree v a -> FingerTree v a -> FingerTree v a

#Split Source

data Split f a

Constructors

#LazySplit Source

data LazySplit f a

Constructors

#splitDigit Source

splitDigit :: forall a v. Monoid v => Measured a v => (v -> Boolean) -> v -> Digit a -> Split Array a

#splitTree Source

splitTree :: forall a v. Monoid v => Measured a v => Partial => (v -> Boolean) -> v -> FingerTree v a -> LazySplit (FingerTree v) a

This function throws an error if the argument is empty.

#split Source

split :: forall a v. Monoid v => Measured a v => Partial => (v -> Boolean) -> FingerTree v a -> Tuple (Lazy (FingerTree v a)) (Lazy (FingerTree v a))

Split a finger tree according to which elements satisfy a predicate. This function is partial because it requires that the result of applying the predicate to mempty is false; if this is not the case, the behaviour is undefined.

#filter Source

filter :: forall a v. Monoid v => Measured a v => (a -> Boolean) -> FingerTree v a -> FingerTree v a

#unfoldLeft Source

unfoldLeft :: forall f a v. Unfoldable f => Monoid v => Measured a v => FingerTree v a -> f a

#unfoldRight Source

unfoldRight :: forall f a v. Unfoldable f => Monoid v => Measured a v => FingerTree v a -> f a

#fullyForce Source

fullyForce :: forall a v. FingerTree v a -> FingerTree v a

Re-exports from Data.FingerTree.Digit

#Digit Source

newtype Digit a

A Digit is just an array which has between one and four elements (inclusive). If a Digit has two or three elements, it is described as 'safe'; otherwise, it is described as 'dangerous'.

Instances

#unsafeIndex Source

unsafeIndex :: forall a. Partial => Digit a -> Int -> a

#tailDigit Source

tailDigit :: forall a. Digit a -> Array a

#snocDigit Source

snocDigit :: forall a. Partial => Digit a -> a -> Digit a

Append a single element. This is partial because the result is not defined in the case where the argument has 4 elements.

#runDigit Source

runDigit :: forall a. Digit a -> Array a

#mkDigitMay Source

mkDigitMay :: forall a. Array a -> Maybe (Digit a)

Like mkDigit, except this returns Nothing on invalid input.

#mkDigit3 Source

mkDigit3 :: forall a. a -> a -> a -> Digit a

#mkDigit2 Source

mkDigit2 :: forall a. a -> a -> Digit a

#mkDigit1 Source

mkDigit1 :: forall a. a -> Digit a

#mkDigit Source

mkDigit :: forall a. Partial => Array a -> Digit a

This function is only defined when the argument has between one and four elements inclusive. It will not throw an error if this is not satisfied, although the Digit length invariant will be violated, which will cause other functions to break.

#lastDigit Source

lastDigit :: forall a. Digit a -> a

#initDigit Source

initDigit :: forall a. Digit a -> Array a

#headDigit Source

headDigit :: forall a. Digit a -> a

#dropDigit Source

dropDigit :: forall a. Int -> Digit a -> Array a

#digitLength Source

digitLength :: forall a. Digit a -> Int

#consDigit Source

consDigit :: forall a. Partial => a -> Digit a -> Digit a

Prepend a single element. This is partial because the result is not defined in the case where the argument has 4 elements.

#(!) Source

Operator alias for Data.FingerTree.Digit.unsafeIndex (non-associative / precedence 2)