union-find-array-0.1.0.3: union find data structure
Safe HaskellNone
LanguageHaskell2010

Control.Monad.Union.Class

Documentation

class Monad m => MonadUnion l m | m -> l where Source #

Methods

new :: l -> m Node Source #

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 :: m () Source #

Flatten the disjoint set forest for faster lookups.

Instances

Instances details
(MonadUnion l m, MonadTrans t, Monad (t m)) => MonadUnion l (t m) Source # 
Instance details

Defined in Control.Monad.Union.Class

Methods

new :: l -> t m Node Source #

lookup :: Node -> t m (Node, l) Source #

merge :: (l -> l -> (l, a)) -> Node -> Node -> t m (Maybe a) Source #

annotate :: Node -> l -> t m () Source #

flatten :: t m () Source #

MonadUnion l (UnionM l) Source # 
Instance details

Defined in Control.Monad.Union

Methods

new :: l -> UnionM l Node Source #

lookup :: Node -> UnionM l (Node, l) Source #

merge :: (l -> l -> (l, a)) -> Node -> Node -> UnionM l (Maybe a) Source #

annotate :: Node -> l -> UnionM l () Source #

flatten :: UnionM l () Source #