non-empty-0.2.1: List-like structures with static restrictions on the number of elements

Safe HaskellSafe-Inferred
LanguageHaskell98

Data.NonEmpty.Class

Synopsis

Documentation

class Empty f where Source

Methods

empty :: f a Source

Instances

class Cons f where Source

Methods

cons :: a -> f a -> f a infixr 5 Source

Instances

Cons [] 
Cons Seq 
Cons f => Cons (T f) 
(Cons f, Empty f) => Cons (T f) 

class Snoc f where Source

Methods

snoc :: f a -> a -> f a Source

Instances

Snoc [] 
Snoc Seq 
Snoc f => Snoc (T f) 

snocDefault :: (Cons f, Traversable f) => f a -> a -> f a Source

class ViewL f where Source

Methods

viewL :: f a -> Maybe (a, f a) Source

Instances

ViewL [] 
ViewL Maybe 
ViewL Set 
ViewL Seq 
ViewL T 
ViewL f => ViewL (T f)

Caution: viewL (NonEmpty.Cons x []) = Nothing because the tail is empty, and thus cannot be NonEmpty!

This instance mainly exist to allow cascaded applications of fetch.

class ViewR f where Source

Methods

viewR :: f a -> Maybe (f a, a) Source

Instances

class (ViewL f, ViewR f) => View f Source

Instances

viewRDefault :: (ViewL f, Traversable f) => f a -> Maybe (f a, a) Source

class Singleton f where Source

Methods

singleton :: a -> f a Source

class Append f where Source

Methods

append :: f a -> f a -> f a infixr 5 Source

Instances

Append [] 
Append Seq 
(Cons f, Append f) => Append (T f) 

class Functor f => Zip f where Source

It must hold:

fmap f xs
   = zipWith (\x _ -> f x) xs xs
   = zipWith (\_ x -> f x) xs xs

Methods

zipWith :: (a -> b -> c) -> f a -> f b -> f c Source

Instances

Zip [] 
Zip Maybe 
Zip Seq 
Zip T 
Zip f => Zip (T f) 
Zip f => Zip (T f) 

zipWith3 :: Zip f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d Source

zipWith4 :: Zip f => (a -> b -> c -> d -> e) -> f a -> f b -> f c -> f d -> f e Source

zip :: Zip f => f a -> f b -> f (a, b) Source

zip3 :: Zip f => f a -> f b -> f c -> f (a, b, c) Source

zip4 :: Zip f => f a -> f b -> f c -> f d -> f (a, b, c, d) Source

class Repeat f where Source

Methods

repeat :: a -> f a Source

Create a container with as many copies as possible of a given value. That is, for a container with fixed size n, the call repeat x will generate a container with n copies of x.

Instances

Repeat [] 
Repeat T 
Repeat f => Repeat (T f) 
Repeat f => Repeat (T f) 

class Repeat f => Iterate f where Source

Methods

iterate :: (a -> a) -> a -> f a Source

Instances

Iterate [] 
Iterate T 
Iterate f => Iterate (T f) 

class Sort f where Source

We need to distinguish between Sort and SortBy, since there is an instance Sort Set but there cannot be an instance SortBy Set.

Methods

sort :: Ord a => f a -> f a Source

Instances

Sort [] 
Sort Maybe 
Sort Set 
Sort Seq 
Sort T 
(Sort f, InsertBy f) => Sort (T f)

If you nest too many non-empty lists then the efficient merge-sort (linear-logarithmic runtime) will degenerate to an inefficient insert-sort (quadratic runtime).

(Insert f, Sort f) => Sort (T f) 

sortDefault :: (Ord a, SortBy f) => f a -> f a Source

Default implementation for sort based on sortBy.

class Sort f => SortBy f where Source

Methods

sortBy :: (a -> a -> Ordering) -> f a -> f a Source

Instances

SortBy [] 
SortBy Maybe 
SortBy Seq 
SortBy T 
(SortBy f, InsertBy f) => SortBy (T f) 
(InsertBy f, SortBy f) => SortBy (T f) 

class Reverse f where Source

Methods

reverse :: f a -> f a Source

Instances

class Show f where Source

Methods

showsPrec :: Show a => Int -> f a -> ShowS Source

Instances

Show [] 
Show Set 
Show T 
Show f => Show (T f) 
Show f => Show (T f) 

class Arbitrary f where Source

Methods

arbitrary :: Arbitrary a => Gen (f a) Source

shrink :: Arbitrary a => f a -> [f a] Source

Instances