mono-traversable-1.0.21.0: Type classes for mapping, folding, and traversing monomorphic containers

Safe Haskell | None
Language | Haskell2010

Data.Sequences

Description

Abstractions over sequential data structures, like lists and vectors.

Synopsis

- class (Integral (Index seq), GrowingAppend seq) => SemiSequence seq where
  - type Index seq
  - intersperse :: Element seq -> seq -> seq
  - reverse :: seq -> seq
  - find :: (Element seq -> Bool) -> seq -> Maybe (Element seq)
  - sortBy :: (Element seq -> Element seq -> Ordering) -> seq -> seq
  - cons :: Element seq -> seq -> seq
  - snoc :: seq -> Element seq -> seq
- singleton :: MonoPointed seq => Element seq -> seq
- class (Monoid seq, MonoTraversable seq, SemiSequence seq, MonoPointed seq) => IsSequence seq where
  - fromList :: [Element seq] -> seq
  - lengthIndex :: seq -> Index seq
  - break :: (Element seq -> Bool) -> seq -> (seq, seq)
  - span :: (Element seq -> Bool) -> seq -> (seq, seq)
  - dropWhile :: (Element seq -> Bool) -> seq -> seq
  - takeWhile :: (Element seq -> Bool) -> seq -> seq
  - splitAt :: Index seq -> seq -> (seq, seq)
  - unsafeSplitAt :: Index seq -> seq -> (seq, seq)
  - take :: Index seq -> seq -> seq
  - unsafeTake :: Index seq -> seq -> seq
  - drop :: Index seq -> seq -> seq
  - unsafeDrop :: Index seq -> seq -> seq
  - dropEnd :: Index seq -> seq -> seq
  - partition :: (Element seq -> Bool) -> seq -> (seq, seq)
  - uncons :: seq -> Maybe (Element seq, seq)
  - unsnoc :: seq -> Maybe (seq, Element seq)
  - filter :: (Element seq -> Bool) -> seq -> seq
  - filterM :: Monad m => (Element seq -> m Bool) -> seq -> m seq
  - replicate :: Index seq -> Element seq -> seq
  - replicateM :: Monad m => Index seq -> m (Element seq) -> m seq
  - groupBy :: (Element seq -> Element seq -> Bool) -> seq -> [seq]
  - groupAllOn :: Eq b => (Element seq -> b) -> seq -> [seq]
  - subsequences :: seq -> [seq]
  - permutations :: seq -> [seq]
  - tailEx :: seq -> seq
  - tailMay :: seq -> Maybe seq
  - initEx :: seq -> seq
  - initMay :: seq -> Maybe seq
  - unsafeTail :: seq -> seq
  - unsafeInit :: seq -> seq
  - index :: seq -> Index seq -> Maybe (Element seq)
  - indexEx :: seq -> Index seq -> Element seq
  - unsafeIndex :: seq -> Index seq -> Element seq
  - splitWhen :: (Element seq -> Bool) -> seq -> [seq]
  - tails :: seq -> [seq]
  - inits :: seq -> [seq]
  - initTails :: seq -> [(seq, seq)]
- defaultFind :: MonoFoldable seq => (Element seq -> Bool) -> seq -> Maybe (Element seq)
- defaultIntersperse :: IsSequence seq => Element seq -> seq -> seq
- defaultReverse :: IsSequence seq => seq -> seq
- defaultSortBy :: IsSequence seq => (Element seq -> Element seq -> Ordering) -> seq -> seq
- defaultSplitWhen :: IsSequence seq => (Element seq -> Bool) -> seq -> [seq]
- vectorSortBy :: Vector v e => (e -> e -> Ordering) -> v e -> v e
- vectorSort :: (Vector v e, Ord e) => v e -> v e
- defaultCons :: IsSequence seq => Element seq -> seq -> seq
- defaultSnoc :: IsSequence seq => seq -> Element seq -> seq
- tailDef :: IsSequence seq => seq -> seq
- initDef :: IsSequence seq => seq -> seq
- splitElem :: (IsSequence seq, Eq (Element seq)) => Element seq -> seq -> [seq]
- splitSeq :: (IsSequence seq, Eq (Element seq)) => seq -> seq -> [seq]
- replaceSeq :: (IsSequence seq, Eq (Element seq)) => seq -> seq -> seq -> seq
- stripPrefix :: (IsSequence seq, Eq (Element seq)) => seq -> seq -> Maybe seq
- stripSuffix :: (IsSequence seq, Eq (Element seq)) => seq -> seq -> Maybe seq
- dropPrefix :: (IsSequence seq, Eq (Element seq)) => seq -> seq -> seq
- dropSuffix :: (IsSequence seq, Eq (Element seq)) => seq -> seq -> seq
- ensurePrefix :: (Eq (Element seq), IsSequence seq) => seq -> seq -> seq
- ensureSuffix :: (Eq (Element seq), IsSequence seq) => seq -> seq -> seq
- isPrefixOf :: (IsSequence seq, Eq (Element seq)) => seq -> seq -> Bool
- isSuffixOf :: (IsSequence seq, Eq (Element seq)) => seq -> seq -> Bool
- isInfixOf :: (IsSequence seq, Eq (Element seq)) => seq -> seq -> Bool
- group :: (IsSequence seq, Eq (Element seq)) => seq -> [seq]
- groupAll :: (IsSequence seq, Eq (Element seq)) => seq -> [seq]
- delete :: (IsSequence seq, Eq (Element seq)) => Element seq -> seq -> seq
- deleteBy :: (IsSequence seq, Eq (Element seq)) => (Element seq -> Element seq -> Bool) -> Element seq -> seq -> seq
- splitElemStrictBS :: Word8 -> ByteString -> [ByteString]
- stripPrefixStrictBS :: ByteString -> ByteString -> Maybe ByteString
- stripSuffixStrictBS :: ByteString -> ByteString -> Maybe ByteString
- splitSeqLazyBS :: Word8 -> ByteString -> [ByteString]
- stripPrefixLazyBS :: ByteString -> ByteString -> Maybe ByteString
- stripSuffixLazyBS :: ByteString -> ByteString -> Maybe ByteString
- splitSeqStrictText :: Text -> Text -> [Text]
- replaceSeqStrictText :: Text -> Text -> Text -> Text
- splitSeqLazyText :: Text -> Text -> [Text]
- replaceSeqLazyText :: Text -> Text -> Text -> Text
- sort :: (SemiSequence seq, Ord (Element seq)) => seq -> seq
- class (IsSequence t, IsString t, Element t ~ Char) => Textual t where
  - words :: t -> [t]
  - unwords :: (Element seq ~ t, MonoFoldable seq) => seq -> t
  - lines :: t -> [t]
  - unlines :: (Element seq ~ t, MonoFoldable seq) => seq -> t
  - toLower :: t -> t
  - toUpper :: t -> t
  - toCaseFold :: t -> t
  - breakWord :: t -> (t, t)
  - breakLine :: t -> (t, t)
- catMaybes :: (IsSequence (f (Maybe t)), Functor f, Element (f (Maybe t)) ~ Maybe t) => f (Maybe t) -> f t
- sortOn :: (Ord o, SemiSequence seq) => (Element seq -> o) -> seq -> seq
- class (IsSequence lazy, IsSequence strict) => LazySequence lazy strict | lazy -> strict, strict -> lazy where
  - toChunks :: lazy -> [strict]
  - fromChunks :: [strict] -> lazy
  - toStrict :: lazy -> strict
  - fromStrict :: strict -> lazy
- pack :: IsSequence seq => [Element seq] -> seq
- unpack :: MonoFoldable mono => mono -> [Element mono]
- repack :: (MonoFoldable a, IsSequence b, Element a ~ Element b) => a -> b
- class (Textual textual, IsSequence binary) => Utf8 textual binary | textual -> binary, binary -> textual where
  - encodeUtf8 :: textual -> binary
  - decodeUtf8 :: binary -> textual

# Documentation

class (Integral (Index seq), GrowingAppend seq) => SemiSequence seq where #

`SemiSequence` was created to share code between `IsSequence` and `NonNull`.

`Semi` means `SemiGroup` A `SemiSequence` can accommodate a `SemiGroup` such as `NonEmpty` or `NonNull` A Monoid should be able to fill out `IsSequence`.

`SemiSequence` operations maintain the same type because they all maintain the same number of elements or increase them. However, a decreasing function such as filter may change they type. For example, from `NonEmpty` to '[]' This type-changing function exists on `NonNull` as `nfilter`

`filter` and other such functions are placed in `IsSequence`

NOTE: Like `GrowingAppend`, ideally we'd have a `Semigroup` superclass constraint here, but that would pull in more dependencies to this package than desired.

Associated Types

type Index seq #

The type of the index of a sequence.

Methods

intersperse :: Element seq -> seq -> seq #

`intersperse` takes an element and intersperses that element between the elements of the sequence.

    > intersperse ',' "abcde"
    "a,b,c,d,e"

reverse :: seq -> seq #

Reverse a sequence

    > reverse "hello world"
    "dlrow olleh"

find :: (Element seq -> Bool) -> seq -> Maybe (Element seq) #

`find` takes a predicate and a sequence and returns the first element in the sequence matching the predicate, or `Nothing` if there isn't an element that matches the predicate.

    > find (== 5) [1 .. 10]
    Just 5

    > find (== 15) [1 .. 10]
    Nothing

sortBy :: (Element seq -> Element seq -> Ordering) -> seq -> seq #

Sort a sequence using an supplied element ordering function.

    > let compare' x y = case compare x y of LT -> GT; EQ -> EQ; GT -> LT
    > sortBy compare' [5,3,6,1,2,4]
    [6,5,4,3,2,1]

cons :: Element seq -> seq -> seq #

Prepend an element onto a sequence.

    > 4 `cons` [1,2,3]
    [4,1,2,3]

snoc :: seq -> Element seq -> seq #

Append an element onto a sequence.

    > [1,2,3] `snoc` 4
    [1,2,3,4]

#### Instances

Instances details

SemiSequence ByteString # |
Instance details Defined in Data.Sequences Associated Types
type Index ByteString |
Instance details Defined in Data.Sequences type Index ByteString = Int
Methods intersperse :: Element ByteString -> ByteString -> ByteString # reverse :: ByteString -> ByteString # find :: (Element ByteString -> Bool) -> ByteString -> Maybe (Element ByteString) # sortBy :: (Element ByteString -> Element ByteString -> Ordering) -> ByteString -> ByteString # cons :: Element ByteString -> ByteString -> ByteString # snoc :: ByteString -> Element ByteString -> ByteString #
SemiSequence ByteString # |
Instance details Defined in Data.Sequences Associated Types
type Index ByteString |
Instance details Defined in Data.Sequences type Index ByteString = Int64
Methods intersperse :: Element ByteString -> ByteString -> ByteString # reverse :: ByteString -> ByteString # find :: (Element ByteString -> Bool) -> ByteString -> Maybe (Element ByteString) # sortBy :: (Element ByteString -> Element ByteString -> Ordering) -> ByteString -> ByteString # cons :: Element ByteString -> ByteString -> ByteString # snoc :: ByteString -> Element ByteString -> ByteString #
SemiSequence Text # |
Instance details Defined in Data.Sequences Associated Types
type Index Text |
Instance details Defined in Data.Sequences type Index Text = Int
Methods intersperse :: Element Text -> Text -> Text # reverse :: Text -> Text # find :: (Element Text -> Bool) -> Text -> Maybe (Element Text) # sortBy :: (Element Text -> Element Text -> Ordering) -> Text -> Text # cons :: Element Text -> Text -> Text # snoc :: Text -> Element Text -> Text #
SemiSequence Text # |
Instance details Defined in Data.Sequences Associated Types
type Index Text |
Instance details Defined in Data.Sequences type Index Text = Int64
Methods intersperse :: Element Text -> Text -> Text # reverse :: Text -> Text # find :: (Element Text -> Bool) -> Text -> Maybe (Element Text) # sortBy :: (Element Text -> Element Text -> Ordering) -> Text -> Text # cons :: Element Text -> Text -> Text # snoc :: Text -> Element Text -> Text #
SemiSequence (Seq a) # |
Instance details Defined in Data.Sequences Associated Types
type Index (Seq a) |
Instance details Defined in Data.Sequences type Index (Seq a) = Int
Methods intersperse :: Element (Seq a) -> Seq a -> Seq a # reverse :: Seq a -> Seq a # find :: (Element (Seq a) -> Bool) -> Seq a -> Maybe (Element (Seq a)) # sortBy :: (Element (Seq a) -> Element (Seq a) -> Ordering) -> Seq a -> Seq a # cons :: Element (Seq a) -> Seq a -> Seq a # snoc :: Seq a -> Element (Seq a) -> Seq a #
SemiSequence (NonEmpty a) # |
Instance details Defined in Data.Sequences Associated Types
type Index (NonEmpty a) |
Instance details Defined in Data.Sequences type Index (NonEmpty a) = Int
Methods intersperse :: Element (NonEmpty a) -> NonEmpty a -> NonEmpty a # reverse :: NonEmpty a -> NonEmpty a # find :: (Element (NonEmpty a) -> Bool) -> NonEmpty a -> Maybe (Element (NonEmpty a)) # sortBy :: (Element (NonEmpty a) -> Element (NonEmpty a) -> Ordering) -> NonEmpty a -> NonEmpty a # cons :: Element (NonEmpty a) -> NonEmpty a -> NonEmpty a # snoc :: NonEmpty a -> Element (NonEmpty a) -> NonEmpty a #
SemiSequence seq => SemiSequence (NonNull seq) # |
Instance details Defined in Data.NonNull Associated Types
type Index (NonNull seq) |
Instance details Defined in Data.NonNull type Index (NonNull seq) = Index seq
Methods intersperse :: Element (NonNull seq) -> NonNull seq -> NonNull seq # reverse :: NonNull seq -> NonNull seq # find :: (Element (NonNull seq) -> Bool) -> NonNull seq -> Maybe (Element (NonNull seq)) # sortBy :: (Element (NonNull seq) -> Element (NonNull seq) -> Ordering) -> NonNull seq -> NonNull seq # cons :: Element (NonNull seq) -> NonNull seq -> NonNull seq # snoc :: NonNull seq -> Element (NonNull seq) -> NonNull seq #
SemiSequence (Vector a) # |
Instance details Defined in Data.Sequences Associated Types
type Index (Vector a) |
Instance details Defined in Data.Sequences type Index (Vector a) = Int
Methods intersperse :: Element (Vector a) -> Vector a -> Vector a # reverse :: Vector a -> Vector a # find :: (Element (Vector a) -> Bool) -> Vector a -> Maybe (Element (Vector a)) # sortBy :: (Element (Vector a) -> Element (Vector a) -> Ordering) -> Vector a -> Vector a # cons :: Element (Vector a) -> Vector a -> Vector a # snoc :: Vector a -> Element (Vector a) -> Vector a #
Storable a => SemiSequence (Vector a) # |
Instance details Defined in Data.Sequences Associated Types
type Index (Vector a) |
Instance details Defined in Data.Sequences type Index (Vector a) = Int
Methods intersperse :: Element (Vector a) -> Vector a -> Vector a # reverse :: Vector a -> Vector a # find :: (Element (Vector a) -> Bool) -> Vector a -> Maybe (Element (Vector a)) # sortBy :: (Element (Vector a) -> Element (Vector a) -> Ordering) -> Vector a -> Vector a # cons :: Element (Vector a) -> Vector a -> Vector a # snoc :: Vector a -> Element (Vector a) -> Vector a #
SemiSequence (Vector a) # | Since: 1.0.21.0
Instance details Defined in Data.Sequences Associated Types
type Index (Vector a) |
Instance details Defined in Data.Sequences type Index (Vector a) = Int
Methods intersperse :: Element (Vector a) -> Vector a -> Vector a # reverse :: Vector a -> Vector a # find :: (Element (Vector a) -> Bool) -> Vector a -> Maybe (Element (Vector a)) # sortBy :: (Element (Vector a) -> Element (Vector a) -> Ordering) -> Vector a -> Vector a # cons :: Element (Vector a) -> Vector a -> Vector a # snoc :: Vector a -> Element (Vector a) -> Vector a #
Unbox a => SemiSequence (Vector a) # |
Instance details Defined in Data.Sequences Associated Types
type Index (Vector a) |
Instance details Defined in Data.Sequences type Index (Vector a) = Int
Methods intersperse :: Element (Vector a) -> Vector a -> Vector a # reverse :: Vector a -> Vector a # find :: (Element (Vector a) -> Bool) -> Vector a -> Maybe (Element (Vector a)) # sortBy :: (Element (Vector a) -> Element (Vector a) -> Ordering) -> Vector a -> Vector a # cons :: Element (Vector a) -> Vector a -> Vector a # snoc :: Vector a -> Element (Vector a) -> Vector a #
SemiSequence [a] # |
Instance details Defined in Data.Sequences Associated Types
type Index [a] |
Instance details Defined in Data.Sequences type Index [a] = Int
Methods intersperse :: Element [a] -> [a] -> [a] # reverse :: [a] -> [a] # find :: (Element [a] -> Bool) -> [a] -> Maybe (Element [a]) # sortBy :: (Element [a] -> Element [a] -> Ordering) -> [a] -> [a] # cons :: Element [a] -> [a] -> [a] # snoc :: [a] -> Element [a] -> [a] #

singleton :: MonoPointed seq => Element seq -> seq #

Create a sequence from a single element.

    > singleton a :: String
    "a"
    > singleton a :: Vector Char
    fromList "a"

class (Monoid seq, MonoTraversable seq, SemiSequence seq, MonoPointed seq) => IsSequence seq where #

Sequence Laws:

    fromList . otoList = id
    fromList (x <> y) = fromList x <> fromList y
    otoList (fromList x <> fromList y) = x <> y

Minimal complete definition

Nothing

Methods

fromList :: [Element seq] -> seq #

Convert a list to a sequence.

    > fromList [a, b, c] :: Text
    "abc"

lengthIndex :: seq -> Index seq #

`lengthIndex` returns the length of a sequence as ``Index` seq`.

Since: 1.0.2

break :: (Element seq -> Bool) -> seq -> (seq, seq) #

`break` applies a predicate to a sequence, and returns a tuple where the first element is the longest prefix (possibly empty) of elements that do not satisfy the predicate. The second element of the tuple is the remainder of the sequence.

``break` p` is equivalent to ``span` (`not` . p)`

    > break (> 3) (fromList [1,2,3,4,1,2,3,4] :: Vector Int)
    (fromList [1,2,3],fromList [4,1,2,3,4])

    > break (< z) (fromList "abc" :: Text)
    ("","abc")

    > break (> z) (fromList "abc" :: Text)
    ("abc","")

span :: (Element seq -> Bool) -> seq -> (seq, seq) #

`span` applies a predicate to a sequence, and returns a tuple where the first element is the longest prefix (possibly empty) that does satisfy the predicate. The second element of the tuple is the remainder of the sequence.

``span` p xs` is equivalent to `(`takeWhile` p xs, `dropWhile` p xs)`

    > span (< 3) (fromList [1,2,3,4,1,2,3,4] :: Vector Int)
    (fromList [1,2],fromList [3,4,1,2,3,4])

    > span (< z) (fromList "abc" :: Text)
    ("abc","")

    > span (< 0) 1,2,3

dropWhile :: (Element seq -> Bool) -> seq -> seq #

`dropWhile` returns the suffix remaining after `takeWhile`.

    > dropWhile (< 3) [1,2,3,4,5,1,2,3]
    [3,4,5,1,2,3]

    > dropWhile (< z) (fromList "abc" :: Text)
    ""

takeWhile :: (Element seq -> Bool) -> seq -> seq #

`takeWhile` applies a predicate to a sequence, and returns the longest prefix (possibly empty) of the sequence of elements that satisfy the predicate.

    > takeWhile (< 3) [1,2,3,4,5,1,2,3]
    [1,2]

    > takeWhile (< z) (fromList "abc" :: Text)
    "abc"

splitAt :: Index seq -> seq -> (seq, seq) #

``splitAt` n se` returns a tuple where the first element is the prefix of the sequence `se` with length `n`, and the second element is the remainder of the sequence.

    > splitAt 6 "Hello world!"
    ("Hello ","world!")

    > splitAt 3 (fromList [1,2,3,4,5] :: Vector Int)
    (fromList [1,2,3],fromList [4,5])

unsafeSplitAt :: Index seq -> seq -> (seq, seq) #

Equivalent to `splitAt`.

take :: Index seq -> seq -> seq #

``take` n` returns the prefix of a sequence of length `n`, or the sequence itself if `n > `olength` seq`.

    > take 3 "abcdefg"
    "abc"
    > take 4 (fromList [1,2,3,4,5,6] :: Vector Int)
    fromList [1,2,3,4]

unsafeTake :: Index seq -> seq -> seq #

Equivalent to `take`.

drop :: Index seq -> seq -> seq #

``drop` n` returns the suffix of a sequence after the first `n` elements, or an empty sequence if `n > `olength` seq`.

    > drop 3 "abcdefg"
    "defg"
    > drop 4 (fromList [1,2,3,4,5,6] :: Vector Int)
    fromList [5,6]

unsafeDrop :: Index seq -> seq -> seq #

Equivalent to `drop`

dropEnd :: Index seq -> seq -> seq #

Same as `drop` but drops from the end of the sequence instead.

    > dropEnd 3 "abcdefg"
    "abcd"
    > dropEnd 4 (fromList [1,2,3,4,5,6] :: Vector Int)
    fromList [1,2]

Since: 1.0.4.0

partition :: (Element seq -> Bool) -> seq -> (seq, seq) #

`partition` takes a predicate and a sequence and returns the pair of sequences of elements which do and do not satisfy the predicate.

    partition p se = (filter p se, filter (not . p) se)

uncons :: seq -> Maybe (Element seq, seq) #

`uncons` returns the tuple of the first element of a sequence and the rest of the sequence, or `Nothing` if the sequence is empty.

    > uncons (fromList [1,2,3,4] :: Vector Int)
    Just (1,fromList [2,3,4])

    > uncons ([] :: [Int])
    Nothing

unsnoc :: seq -> Maybe (seq, Element seq) #

`unsnoc` returns the tuple of the init of a sequence and the last element, or `Nothing` if the sequence is empty.

    > unsnoc (fromList [1,2,3,4] :: Vector Int)
    Just (fromList [1,2,3],4)

    > unsnoc ([] :: [Int])
    Nothing

filter :: (Element seq -> Bool) -> seq -> seq #

`filter` given a predicate returns a sequence of all elements that satisfy the predicate.

    > filter (< 5) [1 .. 10]
    [1,2,3,4]

filterM :: Monad m => (Element seq -> m Bool) -> seq -> m seq #

The monadic version of `filter`.

replicate :: Index seq -> Element seq -> seq #

``replicate` n x` is a sequence of length `n` with `x` as the value of every element.

    > replicate 10 a :: Text
    "aaaaaaaaaa"

replicateM :: Monad m => Index seq -> m (Element seq) -> m seq #

The monadic version of `replicateM`.

groupBy :: (Element seq -> Element seq -> Bool) -> seq -> [seq] #

`group` takes a sequence and returns a list of sequences such that the concatenation of the result is equal to the argument. Each subsequence in the result contains only equal elements, using the supplied equality test.

    > groupBy (==) Mississippi
    [M,"i","ss","i","ss","i","pp","i"]

groupAllOn :: Eq b => (Element seq -> b) -> seq -> [seq] #

Similar to standard `groupBy`, but operates on the whole collection, not just the consecutive items.

subsequences :: seq -> [seq] #

`subsequences` returns a list of all subsequences of the argument.

    > subsequences "abc"
    ["","a","b","ab","c","ac","bc","abc"]

permutations :: seq -> [seq] #

`permutations` returns a list of all permutations of the argument.

    > permutations "abc"
    ["abc","bac","cba","bca","cab","acb"]

tailEx :: seq -> seq #

Unsafe

Get the tail of a sequence, throw an exception if the sequence is empty.

    > tailEx [1,2,3]
    [2,3]

tailMay :: seq -> Maybe seq #

Safe version of `tailEx`.

Returns `Nothing` instead of throwing an exception when encountering an empty monomorphic container.

Since: 1.0.0

initEx :: seq -> seq #

Unsafe

Get the init of a sequence, throw an exception if the sequence is empty.

    > initEx [1,2,3]
    [1,2]

initMay :: seq -> Maybe seq #

Safe version of `initEx`.

Returns `Nothing` instead of throwing an exception when encountering an empty monomorphic container.

Since: 1.0.0

unsafeTail :: seq -> seq #

Equivalent to `tailEx`.

unsafeInit :: seq -> seq #

Equivalent to `initEx`.

index :: seq -> Index seq -> Maybe (Element seq) #

Get the element of a sequence at a certain index, returns `Nothing` if that index does not exist.

    > index (fromList [1,2,3] :: Vector Int) 1
    Just 2
    > index (fromList [1,2,3] :: Vector Int) 4
    Nothing

indexEx :: seq -> Index seq -> Element seq #

Unsafe

Get the element of a sequence at a certain index, throws an exception if the index does not exist.

unsafeIndex :: seq -> Index seq -> Element seq #

Equivalent to `indexEx`.

splitWhen :: (Element seq -> Bool) -> seq -> [seq] #

`splitWhen` splits a sequence into components delimited by separators, where the predicate returns True for a separator element. The resulting components do not contain the separators. Two adjacent separators result in an empty component in the output. The number of resulting components is greater by one than number of separators.

Since 0.9.3

tails :: seq -> [seq] #

Returns all the final segments of `seq` with the longest first.

    > tails [1,2]
    [[1,2],[2],[]]
    > tails []
    [[]]

Since: 1.0.17.0

inits :: seq -> [seq] #

Return all the initial segments of `seq` with the shortest first.

    > inits [1,2]
    [[],[1],[1,2]]
    > inits []
    [[]]

Since: 1.0.17.0

initTails :: seq -> [(seq, seq)] #

Return all the pairs of inital and final segments of `seq`.

    > initTails [1,2]
    [([],[1,2]),([1],[2]),([1,2],[])]
    > initTails []
    [([],[])]

Since: 1.0.17.0

#### Instances

Instances details

IsSequence ByteString # |
Instance details Defined in Data.Sequences Methods fromList :: [Element ByteString] -> ByteString # lengthIndex :: ByteString -> Index ByteString # break :: (Element ByteString -> Bool) -> ByteString -> (ByteString, ByteString) # span :: (Element ByteString -> Bool) -> ByteString -> (ByteString, ByteString) # dropWhile :: (Element ByteString -> Bool) -> ByteString -> ByteString # takeWhile :: (Element ByteString -> Bool) -> ByteString -> ByteString # splitAt :: Index ByteString -> ByteString -> (ByteString, ByteString) # unsafeSplitAt :: Index ByteString -> ByteString -> (ByteString, ByteString) # take :: Index ByteString -> ByteString -> ByteString # unsafeTake :: Index ByteString -> ByteString -> ByteString # drop :: Index ByteString -> ByteString -> ByteString # unsafeDrop :: Index ByteString -> ByteString -> ByteString # dropEnd :: Index ByteString -> ByteString -> ByteString # partition :: (Element ByteString -> Bool) -> ByteString -> (ByteString, ByteString) # uncons :: ByteString -> Maybe (Element ByteString, ByteString) # unsnoc :: ByteString -> Maybe (ByteString, Element ByteString) # filter :: (Element ByteString -> Bool) -> ByteString -> ByteString # filterM :: Monad m => (Element ByteString -> m Bool) -> ByteString -> m ByteString # replicate :: Index ByteString -> Element ByteString -> ByteString # replicateM :: Monad m => Index ByteString -> m (Element ByteString) -> m ByteString # groupBy :: (Element ByteString -> Element ByteString -> Bool) -> ByteString -> [ByteString] # groupAllOn :: Eq b => (Element ByteString -> b) -> ByteString -> [ByteString] # subsequences :: ByteString -> [ByteString] # permutations :: ByteString -> [ByteString] # tailEx :: ByteString -> ByteString # tailMay :: ByteString -> Maybe ByteString # initEx :: ByteString -> ByteString # initMay :: ByteString -> Maybe ByteString # unsafeTail :: ByteString -> ByteString # unsafeInit :: ByteString -> ByteString # index :: ByteString -> Index ByteString -> Maybe (Element ByteString) # indexEx :: ByteString -> Index ByteString -> Element ByteString # unsafeIndex :: ByteString -> Index ByteString -> Element ByteString # splitWhen :: (Element ByteString -> Bool) -> ByteString -> [ByteString] # tails :: ByteString -> [ByteString] # inits :: ByteString -> [ByteString] # initTails :: ByteString -> [(ByteString, ByteString)] #
IsSequence ByteString # |
Instance details Defined in Data.Sequences Methods fromList :: [Element ByteString] -> ByteString # lengthIndex :: ByteString -> Index ByteString # break :: (Element ByteString -> Bool) -> ByteString -> (ByteString, ByteString) # span :: (Element ByteString -> Bool) -> ByteString -> (ByteString, ByteString) # dropWhile :: (Element ByteString -> Bool) -> ByteString -> ByteString # takeWhile :: (Element ByteString -> Bool) -> ByteString -> ByteString # splitAt :: Index ByteString -> ByteString -> (ByteString, ByteString) # unsafeSplitAt :: Index ByteString -> ByteString -> (ByteString, ByteString) # take :: Index ByteString -> ByteString -> ByteString # unsafeTake :: Index ByteString -> ByteString -> ByteString # drop :: Index ByteString -> ByteString -> ByteString # unsafeDrop :: Index ByteString -> ByteString -> ByteString # dropEnd :: Index ByteString -> ByteString -> ByteString # partition :: (Element ByteString -> Bool) -> ByteString -> (ByteString, ByteString) # uncons :: ByteString -> Maybe (Element ByteString, ByteString) # unsnoc :: ByteString -> Maybe (ByteString, Element ByteString) # filter :: (Element ByteString -> Bool) -> ByteString -> ByteString # filterM :: Monad m => (Element ByteString -> m Bool) -> ByteString -> m ByteString # replicate :: Index ByteString -> Element ByteString -> ByteString # replicateM :: Monad m => Index ByteString -> m (Element ByteString) -> m ByteString # groupBy :: (Element ByteString -> Element ByteString -> Bool) -> ByteString -> [ByteString] # groupAllOn :: Eq b => (Element ByteString -> b) -> ByteString -> [ByteString] # subsequences :: ByteString -> [ByteString] # permutations :: ByteString -> [ByteString] # tailEx :: ByteString -> ByteString # tailMay :: ByteString -> Maybe ByteString # initEx :: ByteString -> ByteString # initMay :: ByteString -> Maybe ByteString # unsafeTail :: ByteString -> ByteString # unsafeInit :: ByteString -> ByteString # index :: ByteString -> Index ByteString -> Maybe (Element ByteString) # indexEx :: ByteString -> Index ByteString -> Element ByteString # unsafeIndex :: ByteString -> Index ByteString -> Element ByteString # splitWhen :: (Element ByteString -> Bool) -> ByteString -> [ByteString] # tails :: ByteString -> [ByteString] # inits :: ByteString -> [ByteString] # initTails :: ByteString -> [(ByteString, ByteString)] #
IsSequence Text # |
Instance details Defined in Data.Sequences Methods fromList :: [Element Text] -> Text # lengthIndex :: Text -> Index Text # break :: (Element Text -> Bool) -> Text -> (Text, Text) # span :: (Element Text -> Bool) -> Text -> (Text, Text) # dropWhile :: (Element Text -> Bool) -> Text -> Text # takeWhile :: (Element Text -> Bool) -> Text -> Text # splitAt :: Index Text -> Text -> (Text, Text) # unsafeSplitAt :: Index Text -> Text -> (Text, Text) # take :: Index Text -> Text -> Text # unsafeTake :: Index Text -> Text -> Text # drop :: Index Text -> Text -> Text # unsafeDrop :: Index Text -> Text -> Text # dropEnd :: Index Text -> Text -> Text # partition :: (Element Text -> Bool) -> Text -> (Text, Text) # uncons :: Text -> Maybe (Element Text, Text) # unsnoc :: Text -> Maybe (Text, Element Text) # filter :: (Element Text -> Bool) -> Text -> Text # filterM :: Monad m => (Element Text -> m Bool) -> Text -> m Text # replicate :: Index Text -> Element Text -> Text # replicateM :: Monad m => Index Text -> m (Element Text) -> m Text # groupBy :: (Element Text -> Element Text -> Bool) -> Text -> [Text] # groupAllOn :: Eq b => (Element Text -> b) -> Text -> [Text] # subsequences :: Text -> [Text] # permutations :: Text -> [Text] # tailEx :: Text -> Text # tailMay :: Text -> Maybe Text # initEx :: Text -> Text # initMay :: Text -> Maybe Text # unsafeTail :: Text -> Text # unsafeInit :: Text -> Text # index :: Text -> Index Text -> Maybe (Element Text) # indexEx :: Text -> Index Text -> Element Text # unsafeIndex :: Text -> Index Text -> Element Text # splitWhen :: (Element Text -> Bool) -> Text -> [Text] # tails :: Text -> [Text] # inits :: Text -> [Text] # initTails :: Text -> [(Text, Text)] #
IsSequence Text # |
Instance details Defined in Data.Sequences Methods fromList :: [Element Text] -> Text # lengthIndex :: Text -> Index Text # break :: (Element Text -> Bool) -> Text -> (Text, Text) # span :: (Element Text -> Bool) -> Text -> (Text, Text) # dropWhile :: (Element Text -> Bool) -> Text -> Text # takeWhile :: (Element Text -> Bool) -> Text -> Text # splitAt :: Index Text -> Text -> (Text, Text) # unsafeSplitAt :: Index Text -> Text -> (Text, Text) # take :: Index Text -> Text -> Text # unsafeTake :: Index Text -> Text -> Text # drop :: Index Text -> Text -> Text # unsafeDrop :: Index Text -> Text -> Text # dropEnd :: Index Text -> Text -> Text # partition :: (Element Text -> Bool) -> Text -> (Text, Text) # uncons :: Text -> Maybe (Element Text, Text) # unsnoc :: Text -> Maybe (Text, Element Text) # filter :: (Element Text -> Bool) -> Text -> Text # filterM :: Monad m => (Element Text -> m Bool) -> Text -> m Text # replicate :: Index Text -> Element Text -> Text # replicateM :: Monad m => Index Text -> m (Element Text) -> m Text # groupBy :: (Element Text -> Element Text -> Bool) -> Text -> [Text] # groupAllOn :: Eq b => (Element Text -> b) -> Text -> [Text] # subsequences :: Text -> [Text] # permutations :: Text -> [Text] # tailEx :: Text -> Text # tailMay :: Text -> Maybe Text # initEx :: Text -> Text # initMay :: Text -> Maybe Text # unsafeTail :: Text -> Text # unsafeInit :: Text -> Text # index :: Text -> Index Text -> Maybe (Element Text) # indexEx :: Text -> Index Text -> Element Text # unsafeIndex :: Text -> Index Text -> Element Text # splitWhen :: (Element Text -> Bool) -> Text -> [Text] # tails :: Text -> [Text] # inits :: Text -> [Text] # initTails :: Text -> [(Text, Text)] #
IsSequence (Seq a) # |
Instance details Defined in Data.Sequences Methods fromList :: [Element (Seq a)] -> Seq a # lengthIndex :: Seq a -> Index (Seq a) # break :: (Element (Seq a) -> Bool) -> Seq a -> (Seq a, Seq a) # span :: (Element (Seq a) -> Bool) -> Seq a -> (Seq a, Seq a) # dropWhile :: (Element (Seq a) -> Bool) -> Seq a -> Seq a # takeWhile :: (Element (Seq a) -> Bool) -> Seq a -> Seq a # splitAt :: Index (Seq a) -> Seq a -> (Seq a, Seq a) # unsafeSplitAt :: Index (Seq a) -> Seq a -> (Seq a, Seq a) # take :: Index (Seq a) -> Seq a -> Seq a # unsafeTake :: Index (Seq a) -> Seq a -> Seq a # drop :: Index (Seq a) -> Seq a -> Seq a # unsafeDrop :: Index (Seq a) -> Seq a -> Seq a # dropEnd :: Index (Seq a) -> Seq a -> Seq a # partition :: (Element (Seq a) -> Bool) -> Seq a -> (Seq a, Seq a) # uncons :: Seq a -> Maybe (Element (Seq a), Seq a) # unsnoc :: Seq a -> Maybe (Seq a, Element (Seq a)) # filter :: (Element (Seq a) -> Bool) -> Seq a -> Seq a # filterM :: Monad m => (Element (Seq a) -> m Bool) -> Seq a -> m (Seq a) # replicate :: Index (Seq a) -> Element (Seq a) -> Seq a # replicateM :: Monad m => Index (Seq a) -> m (Element (Seq a)) -> m (Seq a) # groupBy :: (Element (Seq a) -> Element (Seq a) -> Bool) -> Seq a -> [Seq a] # groupAllOn :: Eq b => (Element (Seq a) -> b) -> Seq a -> [Seq a] # subsequences :: Seq a -> [Seq a] # permutations :: Seq a -> [Seq a] # tailEx :: Seq a -> Seq a # tailMay :: Seq a -> Maybe (Seq a) # initEx :: Seq a -> Seq a # initMay :: Seq a -> Maybe (Seq a) # unsafeTail :: Seq a -> Seq a # unsafeInit :: Seq a -> Seq a # index :: Seq a -> Index (Seq a) -> Maybe (Element (Seq a)) # indexEx :: Seq a -> Index (Seq a) -> Element (Seq a) # unsafeIndex :: Seq a -> Index (Seq a) -> Element (Seq a) # splitWhen :: (Element (Seq a) -> Bool) -> Seq a -> [Seq a] # tails :: Seq a -> [Seq a] # inits :: Seq a -> [Seq a] # initTails :: Seq a -> [(Seq a, Seq a)] #
IsSequence (Vector a) # |
Instance details Defined in Data.Sequences Methods fromList :: [Element (Vector a)] -> Vector a # lengthIndex :: Vector a -> Index (Vector a) # break :: (Element (Vector a) -> Bool) -> Vector a -> (Vector a, Vector a) # span :: (Element (Vector a) -> Bool) -> Vector a -> (Vector a, Vector a) # dropWhile :: (Element (Vector a) -> Bool) -> Vector a -> Vector a # takeWhile :: (Element (Vector a) -> Bool) -> Vector a -> Vector a # splitAt :: Index (Vector a) -> Vector a -> (Vector a, Vector a) # unsafeSplitAt :: Index (Vector a) -> Vector a -> (Vector a, Vector a) # take :: Index (Vector a) -> Vector a -> Vector a # unsafeTake :: Index (Vector a) -> Vector a -> Vector a # drop :: Index (Vector a) -> Vector a -> Vector a # unsafeDrop :: Index (Vector a) -> Vector a -> Vector a # dropEnd :: Index (Vector a) -> Vector a -> Vector a # partition :: (Element (Vector a) -> Bool) -> Vector a -> (Vector a, Vector a) # uncons :: Vector a -> Maybe (Element (Vector a), Vector a) # unsnoc :: Vector a -> Maybe (Vector a, Element (Vector a)) # filter :: (Element (Vector a) -> Bool) -> Vector a -> Vector a # filterM :: Monad m => (Element (Vector a) -> m Bool) -> Vector a -> m (Vector a) # replicate :: Index (Vector a) -> Element (Vector a) -> Vector a # replicateM :: Monad m => Index (Vector a) -> m (Element (Vector a)) -> m (Vector a) # groupBy :: (Element (Vector a) -> Element (Vector a) -> Bool) -> Vector a -> [Vector a] # groupAllOn :: Eq b => (Element (Vector a) -> b) -> Vector a -> [Vector a] # subsequences :: Vector a -> [Vector a] # permutations :: Vector a -> [Vector a] # tailEx :: Vector a -> Vector a # tailMay :: Vector a -> Maybe (Vector a) # initEx :: Vector a -> Vector a # initMay :: Vector a -> Maybe (Vector a) # unsafeTail :: Vector a -> Vector a # unsafeInit :: Vector a -> Vector a # index :: Vector a -> Index (Vector a) -> Maybe (Element (Vector a)) # indexEx :: Vector a -> Index (Vector a) -> Element (Vector a) # unsafeIndex :: Vector a -> Index (Vector a) -> Element (Vector a) # splitWhen :: (Element (Vector a) -> Bool) -> Vector a -> [Vector a] # tails :: Vector a -> [Vector a] # inits :: Vector a -> [Vector a] # initTails :: Vector a -> [(Vector a, Vector a)] #
Storable a => IsSequence (Vector a) # |
Instance details Defined in Data.Sequences Methods fromList :: [Element (Vector a)] -> Vector a # lengthIndex :: Vector a -> Index (Vector a) # break :: (Element (Vector a) -> Bool) -> Vector a -> (Vector a, Vector a) # span :: (Element (Vector a) -> Bool) -> Vector a -> (Vector a, Vector a) # dropWhile :: (Element (Vector a) -> Bool) -> Vector a -> Vector a # takeWhile :: (Element (Vector a) -> Bool) -> Vector a -> Vector a # splitAt :: Index (Vector a) -> Vector a -> (Vector a, Vector a) # unsafeSplitAt :: Index (Vector a) -> Vector a -> (Vector a, Vector a) # take :: Index (Vector a) -> Vector a -> Vector a # unsafeTake :: Index (Vector a) -> Vector a -> Vector a # drop :: Index (Vector a) -> Vector a -> Vector a # unsafeDrop :: Index (Vector a) -> Vector a -> Vector a # dropEnd :: Index (Vector a) -> Vector a -> Vector a # partition :: (Element (Vector a) -> Bool) -> Vector a -> (Vector a, Vector a) # uncons :: Vector a -> Maybe (Element (Vector a), Vector a) # unsnoc :: Vector a -> Maybe (Vector a, Element (Vector a)) # filter :: (Element (Vector a) -> Bool) -> Vector a -> Vector a # filterM :: Monad m => (Element (Vector a) -> m Bool) -> Vector a -> m (Vector a) # replicate :: Index (Vector a) -> Element (Vector a) -> Vector a # replicateM :: Monad m => Index (Vector a) -> m (Element (Vector a)) -> m (Vector a) # groupBy :: (Element (Vector a) -> Element (Vector a) -> Bool) -> Vector a -> [Vector a] # groupAllOn :: Eq b => (Element (Vector a) -> b) -> Vector a -> [Vector a] # subsequences :: Vector a -> [Vector a] # permutations :: Vector a -> [Vector a] # tailEx :: Vector a -> Vector a # tailMay :: Vector a -> Maybe (Vector a) # initEx :: Vector a -> Vector a # initMay :: Vector a -> Maybe (Vector a) # unsafeTail :: Vector a -> Vector a # unsafeInit :: Vector a -> Vector a # index :: Vector a -> Index (Vector a) -> Maybe (Element (Vector a)) # indexEx :: Vector a -> Index (Vector a) -> Element (Vector a) # unsafeIndex :: Vector a -> Index (Vector a) -> Element (Vector a) # splitWhen :: (Element (Vector a) -> Bool) -> Vector a -> [Vector a] # tails :: Vector a -> [Vector a] # inits :: Vector a -> [Vector a] # initTails :: Vector a -> [(Vector a, Vector a)] #
IsSequence (Vector a) # | Since: 1.0.21.0
Instance details Defined in Data.Sequences Methods fromList :: [Element (Vector a)] -> Vector a # lengthIndex :: Vector a -> Index (Vector a) # break :: (Element (Vector a) -> Bool) -> Vector a -> (Vector a, Vector a) # span :: (Element (Vector a) -> Bool) -> Vector a -> (Vector a, Vector a) # dropWhile :: (Element (Vector a) -> Bool) -> Vector a -> Vector a # takeWhile :: (Element (Vector a) -> Bool) -> Vector a -> Vector a # splitAt :: Index (Vector a) -> Vector a -> (Vector a, Vector a) # unsafeSplitAt :: Index (Vector a) -> Vector a -> (Vector a, Vector a) # take :: Index (Vector a) -> Vector a -> Vector a # unsafeTake :: Index (Vector a) -> Vector a -> Vector a # drop :: Index (Vector a) -> Vector a -> Vector a # unsafeDrop :: Index (Vector a) -> Vector a -> Vector a # dropEnd :: Index (Vector a) -> Vector a -> Vector a # partition :: (Element (Vector a) -> Bool) -> Vector a -> (Vector a, Vector a) # uncons :: Vector a -> Maybe (Element (Vector a), Vector a) # unsnoc :: Vector a -> Maybe (Vector a, Element (Vector a)) # filter :: (Element (Vector a) -> Bool) -> Vector a -> Vector a # filterM :: Monad m => (Element (Vector a) -> m Bool) -> Vector a -> m (Vector a) # replicate :: Index (Vector a) -> Element (Vector a) -> Vector a # replicateM :: Monad m => Index (Vector a) -> m (Element (Vector a)) -> m (Vector a) # groupBy :: (Element (Vector a) -> Element (Vector a) -> Bool) -> Vector a -> [Vector a] # groupAllOn :: Eq b => (Element (Vector a) -> b) -> Vector a -> [Vector a] # subsequences :: Vector a -> [Vector a] # permutations :: Vector a -> [Vector a] # tailEx :: Vector a -> Vector a # tailMay :: Vector a -> Maybe (Vector a) # initEx :: Vector a -> Vector a # initMay :: Vector a -> Maybe (Vector a) # unsafeTail :: Vector a -> Vector a # unsafeInit :: Vector a -> Vector a # index :: Vector a -> Index (Vector a) -> Maybe (Element (Vector a)) # indexEx :: Vector a -> Index (Vector a) -> Element (Vector a) # unsafeIndex :: Vector a -> Index (Vector a) -> Element (Vector a) # splitWhen :: (Element (Vector a) -> Bool) -> Vector a -> [Vector a] # tails :: Vector a -> [Vector a] # inits :: Vector a -> [Vector a] # initTails :: Vector a -> [(Vector a, Vector a)] #
Unbox a => IsSequence (Vector a) # |
Instance details Defined in Data.Sequences Methods fromList :: [Element (Vector a)] -> Vector a # lengthIndex :: Vector a -> Index (Vector a) # break :: (Element (Vector a) -> Bool) -> Vector a -> (Vector a, Vector a) # span :: (Element (Vector a) -> Bool) -> Vector a -> (Vector a, Vector a) # dropWhile :: (Element (Vector a) -> Bool) -> Vector a -> Vector a # takeWhile :: (Element (Vector a) -> Bool) -> Vector a -> Vector a # splitAt :: Index (Vector a) -> Vector a -> (Vector a, Vector a) # unsafeSplitAt :: Index (Vector a) -> Vector a -> (Vector a, Vector a) # take :: Index (Vector a) -> Vector a -> Vector a # unsafeTake :: Index (Vector a) -> Vector a -> Vector a # drop :: Index (Vector a) -> Vector a -> Vector a # unsafeDrop :: Index (Vector a) -> Vector a -> Vector a # dropEnd :: Index (Vector a) -> Vector a -> Vector a # partition :: (Element (Vector a) -> Bool) -> Vector a -> (Vector a, Vector a) # uncons :: Vector a -> Maybe (Element (Vector a), Vector a) # unsnoc :: Vector a -> Maybe (Vector a, Element (Vector a)) # filter :: (Element (Vector a) -> Bool) -> Vector a -> Vector a # filterM :: Monad m => (Element (Vector a) -> m Bool) -> Vector a -> m (Vector a) # replicate :: Index (Vector a) -> Element (Vector a) -> Vector a # replicateM :: Monad m => Index (Vector a) -> m (Element (Vector a)) -> m (Vector a) # groupBy :: (Element (Vector a) -> Element (Vector a) -> Bool) -> Vector a -> [Vector a] # groupAllOn :: Eq b => (Element (Vector a) -> b) -> Vector a -> [Vector a] # subsequences :: Vector a -> [Vector a] # permutations :: Vector a -> [Vector a] # tailEx :: Vector a -> Vector a # tailMay :: Vector a -> Maybe (Vector a) # initEx :: Vector a -> Vector a # initMay :: Vector a -> Maybe (Vector a) # unsafeTail :: Vector a -> Vector a # unsafeInit :: Vector a -> Vector a # index :: Vector a -> Index (Vector a) -> Maybe (Element (Vector a)) # indexEx :: Vector a -> Index (Vector a) -> Element (Vector a) # unsafeIndex :: Vector a -> Index (Vector a) -> Element (Vector a) # splitWhen :: (Element (Vector a) -> Bool) -> Vector a -> [Vector a] # tails :: Vector a -> [Vector a] # inits :: Vector a -> [Vector a] # initTails :: Vector a -> [(Vector a, Vector a)] #
IsSequence [a] # |
Instance details Defined in Data.Sequences Methods fromList :: [Element [a]] -> [a] # lengthIndex :: [a] -> Index [a] # break :: (Element [a] -> Bool) -> [a] -> ([a], [a]) # span :: (Element [a] -> Bool) -> [a] -> ([a], [a]) # dropWhile :: (Element [a] -> Bool) -> [a] -> [a] # takeWhile :: (Element [a] -> Bool) -> [a] -> [a] # splitAt :: Index [a] -> [a] -> ([a], [a]) # unsafeSplitAt :: Index [a] -> [a] -> ([a], [a]) # take :: Index [a] -> [a] -> [a] # unsafeTake :: Index [a] -> [a] -> [a] # drop :: Index [a] -> [a] -> [a] # unsafeDrop :: Index [a] -> [a] -> [a] # dropEnd :: Index [a] -> [a] -> [a] # partition :: (Element [a] -> Bool) -> [a] -> ([a], [a]) # uncons :: [a] -> Maybe (Element [a], [a]) # unsnoc :: [a] -> Maybe ([a], Element [a]) # filter :: (Element [a] -> Bool) -> [a] -> [a] # filterM :: Monad m => (Element [a] -> m Bool) -> [a] -> m [a] # replicate :: Index [a] -> Element [a] -> [a] # replicateM :: Monad m => Index [a] -> m (Element [a]) -> m [a] # groupBy :: (Element [a] -> Element [a] -> Bool) -> [a] -> [[a]] # groupAllOn :: Eq b => (Element [a] -> b) -> [a] -> [[a]] # subsequences :: [a] -> [[a]] # permutations :: [a] -> [[a]] # tailEx :: [a] -> [a] # tailMay :: [a] -> Maybe [a] # initEx :: [a] -> [a] # initMay :: [a] -> Maybe [a] # unsafeTail :: [a] -> [a] # unsafeInit :: [a] -> [a] # index :: [a] -> Index [a] -> Maybe (Element [a]) # indexEx :: [a] -> Index [a] -> Element [a] # unsafeIndex :: [a] -> Index [a] -> Element [a] # splitWhen :: (Element [a] -> Bool) -> [a] -> [[a]] # tails :: [a] -> [[a]] # inits :: [a] -> [[a]] # initTails :: [a] -> [([a], [a])] #

defaultFind :: MonoFoldable seq => (Element seq -> Bool) -> seq -> Maybe (Element seq) #

Use Data.List's implementation of `find`.

defaultIntersperse :: IsSequence seq => Element seq -> seq -> seq #

Use Data.List's implementation of `intersperse`.

defaultReverse :: IsSequence seq => seq -> seq #

Use Data.List's implementation of `reverse`.

defaultSortBy :: IsSequence seq => (Element seq -> Element seq -> Ordering) -> seq -> seq #

Use Data.List's implementation of `sortBy`.

defaultSplitWhen :: IsSequence seq => (Element seq -> Bool) -> seq -> [seq] #

Use `splitWhen` from Data.List.Split

vectorSortBy :: Vector v e => (e -> e -> Ordering) -> v e -> v e #

Sort a vector using an supplied element ordering function.

vectorSort :: (Vector v e, Ord e) => v e -> v e #

Sort a vector.

defaultCons :: IsSequence seq => Element seq -> seq -> seq #

Use Data.List's `:` to prepend an element to a sequence.

defaultSnoc :: IsSequence seq => seq -> Element seq -> seq #

Use Data.List's `++` to append an element to a sequence.

tailDef :: IsSequence seq => seq -> seq #

like Data.List.tail, but an input of `mempty` returns `mempty`

initDef :: IsSequence seq => seq -> seq #

like Data.List.init, but an input of `mempty` returns `mempty`

splitElem :: (IsSequence seq, Eq (Element seq)) => Element seq -> seq -> [seq] #

``splitElem`` splits a sequence into components delimited by separator element. It's equivalent to `splitWhen` with equality predicate:

    splitElem sep === splitWhen (== sep)

Since 0.9.3

splitSeq :: (IsSequence seq, Eq (Element seq)) => seq -> seq -> [seq] #

``splitSeq`` splits a sequence into components delimited by separator subsequence. `splitSeq` is the right inverse of `intercalate`:

    ointercalate x . splitSeq x === id

`splitElem` can be considered a special case of `splitSeq`

    splitSeq (singleton sep) === splitElem sep

``splitSeq` mempty` is another special case: it splits just before each element, and in line with `splitWhen` rules, it has at least one output component:

    > splitSeq "" ""
    [""]
    > splitSeq "" "a"
    ["", "a"]
    > splitSeq "" "ab"
    ["", "a", "b"]

Since 0.9.3

replaceSeq :: (IsSequence seq, Eq (Element seq)) => seq -> seq -> seq -> seq #

``replaceSeq` old new` replaces all `old` subsequences with `new`.

    replaceSeq old new === ointercalate new . splitSeq old

Since: 1.0.1

stripPrefix :: (IsSequence seq, Eq (Element seq)) => seq -> seq -> Maybe seq #

`stripPrefix` drops the given prefix from a sequence. It returns `Nothing` if the sequence did not start with the prefix given, or `Just` the sequence after the prefix, if it does.

    > stripPrefix "foo" "foobar"
    Just "bar"
    > stripPrefix "abc" "foobar"
    Nothing

stripSuffix :: (IsSequence seq, Eq (Element seq)) => seq -> seq -> Maybe seq #

`stripSuffix` drops the given suffix from a sequence. It returns `Nothing` if the sequence did not end with the suffix given, or `Just` the sequence before the suffix, if it does.

    > stripSuffix "bar" "foobar"
    Just "foo"
    > stripSuffix "abc" "foobar"
    Nothing

dropPrefix :: (IsSequence seq, Eq (Element seq)) => seq -> seq -> seq #

`dropPrefix` drops the given prefix from a sequence. It returns the original sequence if the sequence doesn't start with the given prefix.

    > dropPrefix "foo" "foobar"
    "bar"
    > dropPrefix "abc" "foobar"
    "foobar"

Since: 1.0.7.0

dropSuffix :: (IsSequence seq, Eq (Element seq)) => seq -> seq -> seq #

`dropSuffix` drops the given suffix from a sequence. It returns the original sequence if the sequence doesn't end with the given suffix.

    > dropSuffix "bar" "foobar"
    "foo"
    > dropSuffix "abc" "foobar"
    "foobar"

Since: 1.0.7.0

ensurePrefix :: (Eq (Element seq), IsSequence seq) => seq -> seq -> seq #

`ensurePrefix` will add a prefix to a sequence if it doesn't exist, and otherwise have no effect.

    > ensurePrefix "foo" "foobar"
    "foobar"
    > ensurePrefix "abc" "foobar"
    "abcfoobar"

Since: 1.0.3

ensureSuffix :: (Eq (Element seq), IsSequence seq) => seq -> seq -> seq #

Append a suffix to a sequence, unless it already has that suffix.

    > ensureSuffix "bar" "foobar"
    "foobar"
    > ensureSuffix "abc" "foobar"
    "foobarabc"

Since: 1.0.3

isPrefixOf :: (IsSequence seq, Eq (Element seq)) => seq -> seq -> Bool #

`isPrefixOf` takes two sequences and returns `True` if the first sequence is a prefix of the second.

isSuffixOf :: (IsSequence seq, Eq (Element seq)) => seq -> seq -> Bool #

`isSuffixOf` takes two sequences and returns `True` if the first sequence is a suffix of the second.

isInfixOf :: (IsSequence seq, Eq (Element seq)) => seq -> seq -> Bool #

`isInfixOf` takes two sequences and returns `true` if the first sequence is contained, wholly and intact, anywhere within the second.

group :: (IsSequence seq, Eq (Element seq)) => seq -> [seq] #

Equivalent to ``groupBy` (==)`

groupAll :: (IsSequence seq, Eq (Element seq)) => seq -> [seq] #

Similar to standard `group`, but operates on the whole collection, not just the consecutive items.

Equivalent to ``groupAllOn` id`

delete :: (IsSequence seq, Eq (Element seq)) => Element seq -> seq -> seq #

Since: 0.10.2

deleteBy :: (IsSequence seq, Eq (Element seq)) => (Element seq -> Element seq -> Bool) -> Element seq -> seq -> seq #

Since: 0.10.2

splitElemStrictBS :: Word8 -> ByteString -> [ByteString] #

stripPrefixStrictBS :: ByteString -> ByteString -> Maybe ByteString #

stripSuffixStrictBS :: ByteString -> ByteString -> Maybe ByteString #

splitSeqLazyBS :: Word8 -> ByteString -> [ByteString] #

stripPrefixLazyBS :: ByteString -> ByteString -> Maybe ByteString #

stripSuffixLazyBS :: ByteString -> ByteString -> Maybe ByteString #

splitSeqStrictText :: Text -> Text -> [Text] #

replaceSeqStrictText :: Text -> Text -> Text -> Text #

splitSeqLazyText :: Text -> Text -> [Text] #

replaceSeqLazyText :: Text -> Text -> Text -> Text #

sort :: (SemiSequence seq, Ord (Element seq)) => seq -> seq #

Sort a ordered sequence.

    > sort [4,3,1,2]
    [1,2,3,4]

class (IsSequence t, IsString t, Element t ~ Char) => Textual t where #

A typeclass for sequences whose elements are `Char`s.

Minimal complete definition

words, unwords, lines, unlines, toLower, toUpper, toCaseFold

Methods

words :: t -> [t] #

Break up a textual sequence into a list of words, which were delimited by white space.

    > words "abc  def ghi"
    ["abc","def","ghi"]

unwords :: (Element seq ~ t, MonoFoldable seq) => seq -> t #

Join a list of textual sequences using separating spaces.

    > unwords ["abc","def","ghi"]
    "abc def ghi"

lines :: t -> [t] #

Break up a textual sequence at newline characters.

    > lines "hello\nworld"
    ["hello","world"]

unlines :: (Element seq ~ t, MonoFoldable seq) => seq -> t #

Join a list of textual sequences using newlines.

    > unlines ["abc","def","ghi"]
    "abc\ndef\nghi"

toLower :: t -> t #

Convert a textual sequence to lower-case.

    > toLower "HELLO WORLD"
    "hello world"

toUpper :: t -> t #

Convert a textual sequence to upper-case.

    > toUpper "hello world"
    "HELLO WORLD"

toCaseFold :: t -> t #

Convert a textual sequence to folded-case.

Slightly different from `toLower`, see `Data.Text.`toCaseFold``

breakWord :: t -> (t, t) #

Split a textual sequence into two parts, split at the first space.

    > breakWord "hello world"
    ("hello","world")

breakLine :: t -> (t, t) #

Split a textual sequence into two parts, split at the newline.

    > breakLine "abc\ndef"
    ("abc","def")

#### Instances

Instances details

Textual Text # |
Instance details Defined in Data.Sequences Methods words :: Text -> [Text] # unwords :: (Element seq ~ Text, MonoFoldable seq) => seq -> Text # lines :: Text -> [Text] # unlines :: (Element seq ~ Text, MonoFoldable seq) => seq -> Text # toLower :: Text -> Text # toUpper :: Text -> Text # toCaseFold :: Text -> Text # breakWord :: Text -> (Text, Text) # breakLine :: Text -> (Text, Text) #
Textual Text # |
Instance details Defined in Data.Sequences Methods words :: Text -> [Text] # unwords :: (Element seq ~ Text, MonoFoldable seq) => seq -> Text # lines :: Text -> [Text] # unlines :: (Element seq ~ Text, MonoFoldable seq) => seq -> Text # toLower :: Text -> Text # toUpper :: Text -> Text # toCaseFold :: Text -> Text # breakWord :: Text -> (Text, Text) # breakLine :: Text -> (Text, Text) #
c ~ Char => Textual [c] # |
Instance details Defined in Data.Sequences Methods words :: [c] -> [[c]] # unwords :: (Element seq ~ [c], MonoFoldable seq) => seq -> [c] # lines :: [c] -> [[c]] # unlines :: (Element seq ~ [c], MonoFoldable seq) => seq -> [c] # toLower :: [c] -> [c] # toUpper :: [c] -> [c] # toCaseFold :: [c] -> [c] # breakWord :: [c] -> ([c], [c]) # breakLine :: [c] -> ([c], [c]) #

catMaybes :: (IsSequence (f (Maybe t)), Functor f, Element (f (Maybe t)) ~ Maybe t) => f (Maybe t) -> f t #

Takes all of the `Just` values from a sequence of `Maybe t`s and concatenates them into an unboxed sequence of `t`s.

Since 0.6.2

sortOn :: (Ord o, SemiSequence seq) => (Element seq -> o) -> seq -> seq #

Same as `sortBy . comparing`.

Since 0.7.0

class (IsSequence lazy, IsSequence strict) => LazySequence lazy strict | lazy -> strict, strict -> lazy where #

Lazy sequences containing strict chunks of data.

Since: 1.0.0

Methods

toChunks :: lazy -> [strict] #

fromChunks :: [strict] -> lazy #

toStrict :: lazy -> strict #

fromStrict :: strict -> lazy #

#### Instances

Instances details

LazySequence ByteString ByteString # |
Instance details Defined in Data.Sequences Methods toChunks :: ByteString -> [ByteString] # fromChunks :: [ByteString] -> ByteString # toStrict :: ByteString -> ByteString # fromStrict :: ByteString -> ByteString #
LazySequence Text Text # |
Instance details Defined in Data.Sequences Methods toChunks :: Text -> [Text] # fromChunks :: [Text] -> Text # toStrict :: Text -> Text # fromStrict :: Text -> Text #

pack :: IsSequence seq => [Element seq] -> seq #

Synonym for `fromList`

Since: 1.0.0

unpack :: MonoFoldable mono => mono -> [Element mono] #

Synonym for `otoList`

Since: 1.0.0

repack :: (MonoFoldable a, IsSequence b, Element a ~ Element b) => a -> b #

Repack from one type to another, dropping to a list in the middle.

`repack = pack . unpack`.

Since: 1.0.0

class (Textual textual, IsSequence binary) => Utf8 textual binary | textual -> binary, binary -> textual where #

Textual data which can be encoded to and decoded from UTF8.

Since: 1.0.0

Methods

encodeUtf8 :: textual -> binary #

Encode from textual to binary using UTF-8 encoding

Since: 1.0.0

decodeUtf8 :: binary -> textual #

Note that this function is required to be pure. In the case of a decoding error, Unicode replacement characters must be used.

Since: 1.0.0

#### Instances

Instances details

Utf8 Text ByteString # |
Instance details Defined in Data.Sequences Methods encodeUtf8 :: Text -> ByteString # decodeUtf8 :: ByteString -> Text #
Utf8 Text ByteString # |
Instance details Defined in Data.Sequences Methods encodeUtf8 :: Text -> ByteString # decodeUtf8 :: ByteString -> Text #
(c ~ Char, w ~ Word8) => Utf8 [c] [w] # |
Instance details Defined in Data.Sequences Methods encodeUtf8 :: [c] -> [w] # decodeUtf8 :: [w] -> [c] #