ghc-9.2.2: The GHC API
Safe HaskellSafe-Inferred
LanguageHaskell2010

GHC.Data.UnionFind

Synopsis

Documentation

newtype Point s a Source #

A variable which can be unified; alternately, this can be thought of as an equivalence class with a distinguished representative.

Constructors

Point (STRef s (Link s a)) 

Instances

Instances details
Eq (Point s a) Source # 
Instance details

Defined in GHC.Data.UnionFind

Methods

(==) :: Point s a -> Point s a -> Bool #

(/=) :: Point s a -> Point s a -> Bool #

writePoint :: Point s a -> Link s a -> ST s () Source #

Mutable write to a Point

readPoint :: Point s a -> ST s (Link s a) Source #

Read the current value of Point.

data Link s a Source #

The internal data structure for a Point, which either records the representative element of an equivalence class, or a link to the Point that actually stores the representative type.

Constructors

Info !(STRef s Int) !(STRef s a) 
Link !(Point s a) 

fresh :: a -> ST s (Point s a) Source #

Create a fresh equivalence class with one element.

repr :: Point s a -> ST s (Point s a) Source #

Flatten any chains of links, returning a Point which points directly to the canonical representation.

find :: Point s a -> ST s a Source #

Return the canonical element of an equivalence class Point.

union :: Point s a -> Point s a -> ST s () Source #

Unify two equivalence classes, so that they share a canonical element. Keeps the descriptor of point2.

equivalent :: Point s a -> Point s a -> ST s Bool Source #

Test if two points are in the same equivalence class.