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

Safe HaskellNone
LanguageHaskell2010

Data.Sequences

Description

Warning: This module should be considered highly experimental.

Synopsis

Documentation

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

SemiSequence was created to share code between IsSequence and NonNull. You should always use IsSequence or NonNull rather than using SemiSequence SemiSequence is exported so that you can define new instances of IsSequence or NonNull

Semi means SemiGroup A SemiSequence can accomodate a SemiGroup such as NonEmpty A Monoid should be able to fill out IsSequence

As a base for NonNull, a SemiSequence keeps the same type when increasing its number of elements. However, a decreasing function such as filter may change a NonNull type. For example, from NonEmpty to '[]' This exists on NonNull as nfilter

filter and other such functions are placed in IsSequence

Associated Types

type Index seq

Methods

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 :: IsSequence seq => Element seq -> seq

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

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

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]

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

subsequences :: seq -> [seq]

permutations :: seq -> [seq]

tailEx :: seq -> seq

initEx :: seq -> seq

unsafeTail :: seq -> seq

unsafeInit :: 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

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

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

class (IsSequence seq, Eq (Element seq)) => EqSequence seq where

Minimal complete definition

Nothing

Methods

stripPrefix :: seq -> seq -> Maybe seq

isPrefixOf :: seq -> seq -> Bool

stripSuffix :: seq -> seq -> Maybe seq

isSuffixOf :: seq -> seq -> Bool

isInfixOf :: seq -> seq -> Bool

group :: seq -> [seq]

groupAll :: seq -> [seq]

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

elem :: Element seq -> seq -> Bool

notElem :: Element seq -> seq -> Bool

class (EqSequence seq, MonoFoldableOrd seq) => OrdSequence seq where

Minimal complete definition

Nothing

Methods

sort :: seq -> seq

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

Minimal complete definition

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

Methods

words :: t -> [t]

unwords :: [t] -> t

lines :: t -> [t]

unlines :: [t] -> t

toLower :: t -> t

toUpper :: t -> t

toCaseFold :: t -> t

breakWord :: t -> (t, t)

breakLine :: t -> (t, t)

Instances

Textual Text 
Textual Text 
(~) * c Char => Textual [c]