Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell98 |
- data T a
- insert :: Ord a => a -> Set a -> T a
- singleton :: a -> T a
- member :: Ord a => a -> T a -> Bool
- size :: T a -> Int
- minView :: T a -> (a, Set a)
- maxView :: Ord a => T a -> (a, Set a)
- fromList :: Ord a => T [] a -> T a
- toAscList :: T a -> T [] a
- flatten :: Ord a => T a -> Set a
- union :: Ord a => T a -> T a -> T a
- unionLeft :: Ord a => Set a -> T a -> T a
- unionRight :: Ord a => T a -> Set a -> T a
Documentation
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.