Module

Data.FingerTree

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

data Node v a

Constructors

Instances

#node2

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

#node3

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

#nodeToDigit

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

#FingerTree

data FingerTree v a

Constructors

Instances

#lazyEmpty

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

#deep

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

#eqFingerTree

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

#compareFingerTree

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

#cons

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

#snoc

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

#consAll

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

#snocAll

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

#toFingerTree

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

#ViewL

data ViewL :: (Type -> Type) -> Type -> Typedata ViewL s a

Constructors

Instances

#viewL

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

#deepL

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

#isEmpty

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

#head

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

#tail

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

#ViewR

data ViewR :: (Type -> Type) -> Type -> Typedata ViewR s a

Constructors

#viewR

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

#deepR

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

#last

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

#init

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

#app3

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

#nodes

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

#append

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

#Split

data Split :: (Type -> Type) -> Type -> Typedata Split f a

Constructors

#LazySplit

data LazySplit :: (Type -> Type) -> Type -> Typedata LazySplit f a

Constructors

#splitDigit

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

#splitTree

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

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

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

#unfoldLeft

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

#unfoldRight

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

#fullyForce

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

Re-exports from Data.FingerTree.Digit

#Digit

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

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

#tailDigit

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

#snocDigit

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

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

#mkDigitMay

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

Like mkDigit, except this returns Nothing on invalid input.

#mkDigit3

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

#mkDigit2

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

#mkDigit1

mkDigit1 :: forall a. a -> Digit a

#mkDigit

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

lastDigit :: forall a. Digit a -> a

#initDigit

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

#headDigit

headDigit :: forall a. Digit a -> a

#dropDigit

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

#digitLength

digitLength :: forall a. Digit a -> Int

#consDigit

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.

#(!)

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

Modules