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

Safe HaskellNone

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 aSource

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 aSource

member :: Ord a => a -> T a -> BoolSource

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

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

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

toAscList :: T a -> T [] aSource

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

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

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

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