Safe Haskell | Safe-Inferred |
---|---|

Language | Haskell98 |

## Synopsis

- 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
- fromList :: Ord a => T [] a -> T a
- fromAscList :: Ord a => T [] a -> T a
- toAscList :: T a -> T [] a
- fetch :: Ord a => Set a -> Maybe (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
- findMin :: T a -> a
- findMax :: T a -> a
- delete :: Ord k => k -> T k -> Set k
- deleteMin :: T a -> Set a
- deleteMax :: Ord a => T a -> Set a
- deleteFindMin :: T a -> (a, Set a)
- deleteFindMax :: Ord a => T a -> (a, Set a)
- minView :: T a -> (a, Set a)
- maxView :: Ord a => T a -> (a, Set 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.

deleteFindMin :: T a -> (a, Set a) Source #