data-index-0.1.0.0: Extending the concept of indices for lists and other containers

Safe HaskellSafe
LanguageHaskell2010

Data.Sequence.Index

Description

Redefined index-related functions for Data.Sequence

Synopsis

Documentation

module Data.Index

index :: Seq a -> Index Seq Int -> a Source #

>>> index (Seq.fromList [0..100]) 100
100
>>> index (Seq.fromList [0..100]) end
100
>>> index (Seq.fromList [0..100]) (end-4)
96
>>> index (Seq.fromList [0..100]) 51
51
>>> index (Seq.fromList [0..100]) (mid+1)
51

adjust :: (a -> a) -> Index Seq Int -> Seq a -> Seq a Source #

>>> adjust (pred . pred) 25 (Seq.fromList ['a'..'z'])
fromList "abcdefghijklmnopqrstuvwxyx"
>>> adjust (pred . pred) end (Seq.fromList ['a'..'z'])
fromList "abcdefghijklmnopqrstuvwxyx"
>>> adjust (pred . pred) mid (Seq.fromList ['a'..'z'])
fromList "abcdefghijklmlopqrstuvwxyz"
>>> adjust (pred . pred) (mid+1) (Seq.fromList ['a'..'z'])
fromList "abcdefghijklmnmpqrstuvwxyz"

update :: Index Seq Int -> a -> Seq a -> Seq a Source #

>>> update mid '?' (Seq.fromList ['a'..'z'])
fromList "abcdefghijklm?opqrstuvwxyz"
>>> update 24 '?' (Seq.fromList ['a'..'z'])
fromList "abcdefghijklmnopqrstuvwx?z"
>>> update (end-1) '?' (Seq.fromList ['a'..'z'])
fromList "abcdefghijklmnopqrstuvwx?z"

take :: Index Seq Int -> Seq a -> Seq a Source #

>>> take 10 (Seq.fromList ['a'..'z'])
fromList "abcdefghij"
>>> take (mid - 3) (Seq.fromList ['a'..'z'])
fromList "abcdefghij"

drop :: Index Seq Int -> Seq a -> Seq a Source #

>>> drop 13 (Seq.fromList ['a'..'z'])
fromList "nopqrstuvwxyz"
>>> drop mid (Seq.fromList ['a'..'z'])
fromList "nopqrstuvwxyz"

splitAt :: Index Seq Int -> Seq a -> (Seq a, Seq a) Source #

>>> splitAt mid (Seq.fromList "Hello World!")
(fromList "Hello ",fromList "World!")
>>> splitAt (mid - 1) (Seq.fromList "Hello World!")
(fromList "Hello",fromList " World!")