Safe Haskell | None |
---|---|
Language | Haskell2010 |
Strict variants of
FingerTree
operations.
Synopsis
- data StrictFingerTree v a
- fromStrict :: StrictFingerTree v a -> FingerTree v a
- forceToStrict :: FingerTree v a -> StrictFingerTree v a
- empty :: Measured v a => StrictFingerTree v a
- singleton :: Measured v a => a -> StrictFingerTree v a
- (<|) :: Measured v a => a -> StrictFingerTree v a -> StrictFingerTree v a
- (|>) :: Measured v a => StrictFingerTree v a -> a -> StrictFingerTree v a
- (><) :: Measured v a => StrictFingerTree v a -> StrictFingerTree v a -> StrictFingerTree v a
- fromList :: Measured v a => [a] -> StrictFingerTree v a
- null :: StrictFingerTree v a -> Bool
- viewl :: Measured v a => StrictFingerTree v a -> ViewL ( StrictFingerTree v) a
- viewr :: Measured v a => StrictFingerTree v a -> ViewR ( StrictFingerTree v) a
-
data
SearchResult
v a
- = Position !( StrictFingerTree v a) !a !( StrictFingerTree v a)
- | OnLeft
- | OnRight
- | Nowhere
- search :: Measured v a => (v -> v -> Bool ) -> StrictFingerTree v a -> SearchResult v a
- split :: Measured v a => (v -> Bool ) -> StrictFingerTree v a -> ( StrictFingerTree v a, StrictFingerTree v a)
- takeUntil :: Measured v a => (v -> Bool ) -> StrictFingerTree v a -> StrictFingerTree v a
- dropUntil :: Measured v a => (v -> Bool ) -> StrictFingerTree v a -> StrictFingerTree v a
- reverse :: Measured v a => StrictFingerTree v a -> StrictFingerTree v a
- fmap' :: ( Measured v1 a1, Measured v2 a2) => (a1 -> a2) -> StrictFingerTree v1 a1 -> StrictFingerTree v2 a2
- unsafeFmap :: (a -> b) -> StrictFingerTree v a -> StrictFingerTree v b
-
class
Monoid
v =>
Measured
v a | a -> v
where
- measure :: a -> v
- data ViewL (s :: Type -> Type ) a
- data ViewR (s :: Type -> Type ) a
Documentation
data StrictFingerTree v a Source #
A
newtype
wrapper around a
FingerTree
, representing a finger tree
that is strict in its values.
This strictness is not enforced at the type level, but rather by the construction functions in this module. These functions essentially just wrap the original Data.FingerTree functions while forcing the provided value to WHNF.
Instances
fromStrict :: StrictFingerTree v a -> FingerTree v a Source #
forceToStrict :: FingerTree v a -> StrictFingerTree v a Source #
Convert a
FingerTree
into a
StrictFingerTree
by forcing each element
to WHNF.
Construction
empty :: Measured v a => StrictFingerTree v a Source #
O(1) . The empty sequence.
singleton :: Measured v a => a -> StrictFingerTree v a Source #
O(1) . A singleton sequence.
(<|) :: Measured v a => a -> StrictFingerTree v a -> StrictFingerTree v a infixr 5 Source #
O(1) . Add an element to the left end of a sequence. Mnemonic: a triangle with the single element at the pointy end.
(|>) :: Measured v a => StrictFingerTree v a -> a -> StrictFingerTree v a infixl 5 Source #
O(1) . Add an element to the right end of a sequence. Mnemonic: a triangle with the single element at the pointy end.
(><) :: Measured v a => StrictFingerTree v a -> StrictFingerTree v a -> StrictFingerTree v a infixr 5 Source #
O(log(min(n1,n2))) . Concatenate two sequences.
fromList :: Measured v a => [a] -> StrictFingerTree v a Source #
Deconstruction
null :: StrictFingerTree v a -> Bool Source #
O(1) . Is this the empty sequence?
Examining the ends
viewl :: Measured v a => StrictFingerTree v a -> ViewL ( StrictFingerTree v) a Source #
O(1) . Analyse the left end of a sequence.
viewr :: Measured v a => StrictFingerTree v a -> ViewR ( StrictFingerTree v) a Source #
O(1) . Analyse the right end of a sequence.
Search
data SearchResult v a Source #
A result of
search
, attempting to find a point where a predicate
on splits of the sequence changes from
False
to
True
.
Since: 0.1.2.0
Position !( StrictFingerTree v a) !a !( StrictFingerTree v a) |
A tree opened at a particular element: the prefix to the left, the element, and the suffix to the right. |
OnLeft |
A position to the left of the sequence, indicating that the
predicate is
|
OnRight |
A position to the right of the sequence, indicating that the
predicate is
|
Nowhere |
No position in the tree, returned if the predicate is
|
Instances
search :: Measured v a => (v -> v -> Bool ) -> StrictFingerTree v a -> SearchResult v a Source #
O(log(min(i,n-i)))
. Search a sequence for a point where a predicate
on splits of the sequence changes from
False
to
True
.
The argument
p
is a relation between the measures of the two
sequences that could be appended together to form the sequence
t
.
If the relation is
False
at the leftmost split and
True
at the
rightmost split, i.e.
not (pmempty
(measure
t)) && p (measure
t)mempty
then there must exist an element
x
in the sequence such that
p
is
False
for the split immediately before
x
and
True
for the
split just after it:
In this situation,
returns such an element
search
p t
x
and the
pieces
l
and
r
of the sequence to its left and right respectively.
That is, it returns
such that
Position
l x r
-
l >< (x <| r) = t
-
not (p (measure l) (measure (x <| r))
-
p (measure (l |> x)) (measure r)
For predictable results, one should ensure that there is only one such
point, i.e. that the predicate is
monotonic
on
t
.
Since: 0.1.2.0
Splitting
These functions are special cases of
search
.
split :: Measured v a => (v -> Bool ) -> StrictFingerTree v a -> ( StrictFingerTree v a, StrictFingerTree v a) Source #
takeUntil :: Measured v a => (v -> Bool ) -> StrictFingerTree v a -> StrictFingerTree v a Source #
dropUntil :: Measured v a => (v -> Bool ) -> StrictFingerTree v a -> StrictFingerTree v a Source #
Transformation
reverse :: Measured v a => StrictFingerTree v a -> StrictFingerTree v a Source #
O(n) . The reverse of a sequence.
Maps
fmap' :: ( Measured v1 a1, Measured v2 a2) => (a1 -> a2) -> StrictFingerTree v1 a1 -> StrictFingerTree v2 a2 Source #
Like
fmap
, but with constraints on the element types.
unsafeFmap :: (a -> b) -> StrictFingerTree v a -> StrictFingerTree v b Source #
Like
fmap
, but safe only if the function preserves the measure.
class Monoid v => Measured v a | a -> v where Source #
Things that can be measured.
Instances
Measured v a => Measured v (Digit a) | |
Defined in Data.FingerTree |
|
Measured v a => Measured v ( StrictFingerTree v a) Source # | |
Defined in Data.FingerTree.Strict measure :: StrictFingerTree v a -> v Source # |
|
Monoid v => Measured v (Node v a) | |
Defined in Data.FingerTree |
|
Measured v a => Measured v ( FingerTree v a) |
O(1) . The cached measure of a tree. |
Defined in Data.FingerTree measure :: FingerTree v a -> v Source # |
data ViewL (s :: Type -> Type ) a Source #
View of the left end of a sequence.
Instances
Functor s => Functor ( ViewL s) | |
( Eq a, Eq (s a)) => Eq ( ViewL s a) | |
( Ord a, Ord (s a)) => Ord ( ViewL s a) | |
Defined in Data.FingerTree |
|
( Read a, Read (s a)) => Read ( ViewL s a) | |
( Show a, Show (s a)) => Show ( ViewL s a) | |
Generic ( ViewL s a) | |
type Rep ( ViewL s a) | |
Defined in Data.FingerTree
type
Rep
(
ViewL
s a) =
D1
('
MetaData
"ViewL" "Data.FingerTree" "fingertree-0.1.5.0-9rC7ZsLgw7G1xI3Y5mn8pM" '
False
) (
C1
('
MetaCons
"EmptyL" '
PrefixI
'
False
) (
U1
::
Type
->
Type
)
:+:
C1
('
MetaCons
":<" ('
InfixI
'
RightAssociative
5) '
False
) (
S1
('
MetaSel
('
Nothing
::
Maybe
Symbol
) '
NoSourceUnpackedness
'
NoSourceStrictness
'
DecidedLazy
) (
Rec0
a)
:*:
S1
('
MetaSel
('
Nothing
::
Maybe
Symbol
) '
NoSourceUnpackedness
'
NoSourceStrictness
'
DecidedLazy
) (
Rec0
(s a))))
|
data ViewR (s :: Type -> Type ) a Source #
View of the right end of a sequence.
EmptyR |
empty sequence |
(s a) :> a infixl 5 |
the sequence minus the rightmost element, and the rightmost element |
Instances
Functor s => Functor ( ViewR s) | |
( Eq a, Eq (s a)) => Eq ( ViewR s a) | |
( Ord a, Ord (s a)) => Ord ( ViewR s a) | |
Defined in Data.FingerTree |
|
( Read a, Read (s a)) => Read ( ViewR s a) | |
( Show a, Show (s a)) => Show ( ViewR s a) | |
Generic ( ViewR s a) | |
type Rep ( ViewR s a) | |
Defined in Data.FingerTree
type
Rep
(
ViewR
s a) =
D1
('
MetaData
"ViewR" "Data.FingerTree" "fingertree-0.1.5.0-9rC7ZsLgw7G1xI3Y5mn8pM" '
False
) (
C1
('
MetaCons
"EmptyR" '
PrefixI
'
False
) (
U1
::
Type
->
Type
)
:+:
C1
('
MetaCons
":>" ('
InfixI
'
LeftAssociative
5) '
False
) (
S1
('
MetaSel
('
Nothing
::
Maybe
Symbol
) '
NoSourceUnpackedness
'
NoSourceStrictness
'
DecidedLazy
) (
Rec0
(s a))
:*:
S1
('
MetaSel
('
Nothing
::
Maybe
Symbol
) '
NoSourceUnpackedness
'
NoSourceStrictness
'
DecidedLazy
) (
Rec0
a)))
|