Safe Haskell | Safe |
---|---|
Language | Haskell98 |
- data Set n where
- type Union s t = Nub (Sort (Append s t))
- type Unionable s t = (Sortable (Append s t), Nubable (Sort (Append s t)))
- union :: Unionable s t => Set s -> Set t -> Set (Union s t)
- quicksort :: Sortable xs => Set xs -> Set (Sort xs)
- append :: Set s -> Set t -> Set (Append s t)
- type family Sort (xs :: [k]) :: [k] where ...
- class Sortable xs where
- type family Append (s :: [k]) (t :: [k]) :: [k] where ...
- class Split s t st where
- type family Cmp (a :: k) (b :: k) :: Ordering
- type family Nub t where ...
- class Nubable t where
- type AsSet s = Nub (Sort s)
- asSet :: (Sortable s, Nubable (Sort s)) => Set s -> Set (AsSet s)
- type IsSet s = s ~ Nub (Sort s)
- class Subset s t where
- data k :-> v = (Var k) :-> v
- data Var k where
Documentation
Core Set definition, in terms of lists
type family Sort (xs :: [k]) :: [k] where ... Source #
Type-level quick sort for normalising the representation of sets
type family Append (s :: [k]) (t :: [k]) :: [k] where ... Source #
List append (essentially set disjoint union)
type family Cmp (a :: k) (b :: k) :: Ordering Source #
Open-family for the ordering operation in the sort
class Nubable t where Source #
Value-level counterpart to the type-level Nub
Note: the value-level case for equal types is not define here,
but should be given per-application, e.g., custom merging
behaviour may be required
asSet :: (Sortable s, Nubable (Sort s)) => Set s -> Set (AsSet s) Source #
At the value level, noramlise the list form to the set form