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

Safe HaskellSafe
LanguageHaskell98

Data.NonEmpty.Class

Synopsis

Documentation

class Empty f where #

Minimal complete definition

empty

Methods

empty :: f a #

Instances

Empty [] # 

Methods

empty :: [a] #

Empty Maybe # 

Methods

empty :: Maybe a #

Empty Seq # 

Methods

empty :: Seq a #

Empty Set # 

Methods

empty :: Set a #

Empty T # 

Methods

empty :: T a #

Empty (Map k) # 

Methods

empty :: Map k a #

Empty (T f) # 

Methods

empty :: T f a #

class Cons f where #

Minimal complete definition

cons

Methods

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

Instances

Cons [] # 

Methods

cons :: a -> [a] -> [a] #

Cons Seq # 

Methods

cons :: a -> Seq a -> Seq a #

Cons f => Cons (T f) # 

Methods

cons :: a -> T f a -> T f a #

(Cons f, Empty f) => Cons (T f) # 

Methods

cons :: a -> T f a -> T f a #

class Snoc f where #

Minimal complete definition

snoc

Methods

snoc :: f a -> a -> f a #

Instances

Snoc [] # 

Methods

snoc :: [a] -> a -> [a] #

Snoc Seq # 

Methods

snoc :: Seq a -> a -> Seq a #

Snoc f => Snoc (T f) # 

Methods

snoc :: T f a -> a -> T f a #

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

class ViewL f where #

Minimal complete definition

viewL

Methods

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

Instances

ViewL [] # 

Methods

viewL :: [a] -> Maybe (a, [a]) #

ViewL Maybe # 

Methods

viewL :: Maybe a -> Maybe (a, Maybe a) #

ViewL Seq # 

Methods

viewL :: Seq a -> Maybe (a, Seq a) #

ViewL Set # 

Methods

viewL :: Set a -> Maybe (a, Set a) #

ViewL T # 

Methods

viewL :: T a -> Maybe (a, T a) #

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.

Methods

viewL :: T f a -> Maybe (a, T f a) #

class ViewR f where #

Minimal complete definition

viewR

Methods

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

Instances

ViewR [] # 

Methods

viewR :: [a] -> Maybe ([a], a) #

ViewR Maybe # 

Methods

viewR :: Maybe a -> Maybe (Maybe a, a) #

ViewR Seq # 

Methods

viewR :: Seq a -> Maybe (Seq a, a) #

ViewR Set # 

Methods

viewR :: Set a -> Maybe (Set a, a) #

ViewR T # 

Methods

viewR :: T a -> Maybe (T a, a) #

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

Instances

View [] # 
View Maybe # 
View Seq # 
View Set # 
View T # 

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

class Singleton f where #

Minimal complete definition

singleton

Methods

singleton :: a -> f a #

Instances

Singleton [] # 

Methods

singleton :: a -> [a] #

Singleton Maybe # 

Methods

singleton :: a -> Maybe a #

Singleton Seq # 

Methods

singleton :: a -> Seq a #

Singleton Set # 

Methods

singleton :: a -> Set a #

Empty f => Singleton (T f) # 

Methods

singleton :: a -> T f a #

class Append f where #

Minimal complete definition

append

Methods

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

Instances

Append [] # 

Methods

append :: [a] -> [a] -> [a] #

Append Seq # 

Methods

append :: Seq a -> Seq a -> Seq a #

(Cons f, Append f) => Append (T f) # 

Methods

append :: T f a -> T f a -> T f a #

class Functor f => Zip f where #

It must hold:

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

Minimal complete definition

zipWith

Methods

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

Instances

Zip [] # 

Methods

zipWith :: (a -> b -> c) -> [a] -> [b] -> [c] #

Zip Maybe # 

Methods

zipWith :: (a -> b -> c) -> Maybe a -> Maybe b -> Maybe c #

Zip Seq # 

Methods

zipWith :: (a -> b -> c) -> Seq a -> Seq b -> Seq c #

Zip T # 

Methods

zipWith :: (a -> b -> c) -> T a -> T b -> T c #

Zip f => Zip (T f) # 

Methods

zipWith :: (a -> b -> c) -> T f a -> T f b -> T f c #

Zip f => Zip (T f) # 

Methods

zipWith :: (a -> b -> c) -> T f a -> T f b -> T f c #

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

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

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

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

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

class Repeat f where #

Minimal complete definition

repeat

Methods

repeat :: a -> f a #

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 [] # 

Methods

repeat :: a -> [a] #

Repeat Maybe # 

Methods

repeat :: a -> Maybe a #

Repeat T # 

Methods

repeat :: a -> T a #

Repeat f => Repeat (T f) # 

Methods

repeat :: a -> T f a #

Repeat f => Repeat (T f) # 

Methods

repeat :: a -> T f a #

class Repeat f => Iterate f where #

Minimal complete definition

iterate

Methods

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

Instances

Iterate [] # 

Methods

iterate :: (a -> a) -> a -> [a] #

Iterate Maybe # 

Methods

iterate :: (a -> a) -> a -> Maybe a #

Iterate T # 

Methods

iterate :: (a -> a) -> a -> T a #

Iterate f => Iterate (T f) # 

Methods

iterate :: (a -> a) -> a -> T f a #

Iterate f => Iterate (T f) # 

Methods

iterate :: (a -> a) -> a -> T f a #

class Sort f where #

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

Minimal complete definition

sort

Methods

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

Instances

Sort [] # 

Methods

sort :: Ord a => [a] -> [a] #

Sort Maybe # 

Methods

sort :: Ord a => Maybe a -> Maybe a #

Sort Seq # 

Methods

sort :: Ord a => Seq a -> Seq a #

Sort Set # 

Methods

sort :: Ord a => Set a -> Set a #

Sort T # 

Methods

sort :: Ord a => T a -> T a #

(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).

Methods

sort :: Ord a => T f a -> T f a #

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

Methods

sort :: Ord a => T f a -> T f a #

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

Default implementation for sort based on sortBy.

class Sort f => SortBy f where #

Minimal complete definition

sortBy

Methods

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

Instances

SortBy [] # 

Methods

sortBy :: (a -> a -> Ordering) -> [a] -> [a] #

SortBy Maybe # 

Methods

sortBy :: (a -> a -> Ordering) -> Maybe a -> Maybe a #

SortBy Seq # 

Methods

sortBy :: (a -> a -> Ordering) -> Seq a -> Seq a #

SortBy T # 

Methods

sortBy :: (a -> a -> Ordering) -> T a -> T a #

(SortBy f, InsertBy f) => SortBy (T f) # 

Methods

sortBy :: (a -> a -> Ordering) -> T f a -> T f a #

(InsertBy f, SortBy f) => SortBy (T f) # 

Methods

sortBy :: (a -> a -> Ordering) -> T f a -> T f a #

class Reverse f where #

Minimal complete definition

reverse

Methods

reverse :: f a -> f a #

Instances

Reverse [] # 

Methods

reverse :: [a] -> [a] #

Reverse Maybe # 

Methods

reverse :: Maybe a -> Maybe a #

Reverse Seq # 

Methods

reverse :: Seq a -> Seq a #

Reverse T # 

Methods

reverse :: T a -> T a #

(Traversable f, Reverse f) => Reverse (T f) # 

Methods

reverse :: T f a -> T f a #

(Traversable f, Reverse f) => Reverse (T f) # 

Methods

reverse :: T f a -> T f a #

class Show f where #

Minimal complete definition

showsPrec

Methods

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

Instances

Show [] # 

Methods

showsPrec :: Show a => Int -> [a] -> ShowS #

Show Set # 

Methods

showsPrec :: Show a => Int -> Set a -> ShowS #

Show T # 

Methods

showsPrec :: Show a => Int -> T a -> ShowS #

Show f => Show (T f) # 

Methods

showsPrec :: Show a => Int -> T f a -> ShowS #

Show f => Show (T f) # 

Methods

showsPrec :: Show a => Int -> T f a -> ShowS #

class Arbitrary f where #

Minimal complete definition

arbitrary, shrink

Methods

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

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

Instances

Arbitrary [] # 

Methods

arbitrary :: Arbitrary a => Gen [a] #

shrink :: Arbitrary a => [a] -> [[a]] #

Arbitrary f => Arbitrary (T f) # 

Methods

arbitrary :: Arbitrary a => Gen (T f a) #

shrink :: Arbitrary a => T f a -> [T f a] #

class NFData f where #

Minimal complete definition

rnf

Methods

rnf :: NFData a => f a -> () #

Instances

NFData [] # 

Methods

rnf :: NFData a => [a] -> () #

NFData Maybe # 

Methods

rnf :: NFData a => Maybe a -> () #

NFData Set # 

Methods

rnf :: NFData a => Set a -> () #

NFData T # 

Methods

rnf :: NFData a => T a -> () #

NFData T # 

Methods

rnf :: NFData a => T a -> () #

NFData k => NFData (Map k) # 

Methods

rnf :: NFData a => Map k a -> () #

NFData f => NFData (T f) # 

Methods

rnf :: NFData a => T f a -> () #

NFData k => NFData (T k) # 

Methods

rnf :: NFData a => T k a -> () #

NFData f => NFData (T f) # 

Methods

rnf :: NFData a => T f a -> () #

NFData f => NFData (T f) # 

Methods

rnf :: NFData a => T f a -> () #

(NFData f, NFData g) => NFData (T f g) # 

Methods

rnf :: NFData a => T f g a -> () #