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

Safe HaskellSafe-Inferred
LanguageHaskell98

Data.NonEmpty.Set

Synopsis

Documentation

data T a Source

Instances

Eq a => Eq (T a) 
Ord a => Ord (T a) 
Show a => Show (T a) 

insert :: Ord a => a -> Set a -> T a Source

We cannot have a reasonable instance Insert Set, since the instance Insert (NonEmpty Set) would preserve duplicate leading elements, whereas Set does not.

However, the instance Insert NonEmpty is not the problem. A general type like

insertSet :: (Insert f, Ord a) => a -> f a -> NonEmpty f a

cannot work, since it can be instantiated to

insertSet :: (Ord a) => a -> NonEmpty Set a -> NonEmpty (NonEmpty Set) a

and this is obviously wrong: insertSet x (singleton x) has only one element, not two.

singleton :: a -> T a Source

member :: Ord a => a -> T a -> Bool Source

size :: T a -> Int Source

minView :: T a -> (a, Set a) Source

maxView :: Ord a => T a -> (a, Set a) Source

fromList :: Ord a => T [] a -> T a Source

toAscList :: T a -> T [] a Source

flatten :: Ord a => T a -> Set a Source

union :: Ord a => T a -> T a -> T a Source

unionLeft :: Ord a => Set a -> T a -> T a Source

unionRight :: Ord a => T a -> Set a -> T a Source