Safe Haskell | None |
---|
Control.Monad.Union
Description
Monadic interface for creating a disjoint set data structure.
Documentation
Union find monad.
Instances
MonadUnion l (UnionM l) | |
Monad (UnionM l) | |
Functor (UnionM l) | |
MonadFix (UnionM l) | |
Applicative (UnionM l) |
An immutable disjoint set forest.
class Monad m => MonadUnion l m | m -> l whereSource
Methods
Add a new node, with a given label.
lookup :: Node -> m (Node, l)Source
Find the node representing a given node, and its label.
merge :: (l -> l -> (l, a)) -> Node -> Node -> m (Maybe a)Source
Merge two sets. The first argument is a function that takes the labels of the corresponding sets' representatives and computes a new label for the joined set. Returns Nothing if the given nodes are in the same set already.
annotate :: Node -> l -> m ()Source
Re-label a node.
Flatten the disjoint set forest for faster lookups.
Instances
(MonadUnion l m, MonadTrans t, Monad (t m)) => MonadUnion l (t m) | |
MonadUnion l (UnionM l) |