-- This file is part of the 'union-find-array' library. It is licensed
-- under an MIT license. See the accompanying 'LICENSE' file for details.
--
-- Authors: Bertram Felgenhauer

{-# LANGUAGE GeneralizedNewtypeDeriving #-}

module Data.Union.Type (
    Union (..),
    Node (..),
) where

import Data.Array.Unboxed
import Data.Array

-- | An immutable disjoint set forest.
data Union a = Union {
    forall a. Union a -> Int
size  :: !Int,
    forall a. Union a -> UArray Int Int
up    :: UArray Int Int,
    forall a. Union a -> Array Int a
label :: Array Int a
}

-- | A node in a disjoint set forest.
newtype Node = Node { Node -> Int
fromNode :: Int }
    deriving (Node -> Node -> Bool
(Node -> Node -> Bool) -> (Node -> Node -> Bool) -> Eq Node
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Node -> Node -> Bool
== :: Node -> Node -> Bool
$c/= :: Node -> Node -> Bool
/= :: Node -> Node -> Bool
Eq, Eq Node
Eq Node =>
(Node -> Node -> Ordering)
-> (Node -> Node -> Bool)
-> (Node -> Node -> Bool)
-> (Node -> Node -> Bool)
-> (Node -> Node -> Bool)
-> (Node -> Node -> Node)
-> (Node -> Node -> Node)
-> Ord Node
Node -> Node -> Bool
Node -> Node -> Ordering
Node -> Node -> Node
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Node -> Node -> Ordering
compare :: Node -> Node -> Ordering
$c< :: Node -> Node -> Bool
< :: Node -> Node -> Bool
$c<= :: Node -> Node -> Bool
<= :: Node -> Node -> Bool
$c> :: Node -> Node -> Bool
> :: Node -> Node -> Bool
$c>= :: Node -> Node -> Bool
>= :: Node -> Node -> Bool
$cmax :: Node -> Node -> Node
max :: Node -> Node -> Node
$cmin :: Node -> Node -> Node
min :: Node -> Node -> Node
Ord, Ord Node
Ord Node =>
((Node, Node) -> [Node])
-> ((Node, Node) -> Node -> Int)
-> ((Node, Node) -> Node -> Int)
-> ((Node, Node) -> Node -> Bool)
-> ((Node, Node) -> Int)
-> ((Node, Node) -> Int)
-> Ix Node
(Node, Node) -> Int
(Node, Node) -> [Node]
(Node, Node) -> Node -> Bool
(Node, Node) -> Node -> Int
forall a.
Ord a =>
((a, a) -> [a])
-> ((a, a) -> a -> Int)
-> ((a, a) -> a -> Int)
-> ((a, a) -> a -> Bool)
-> ((a, a) -> Int)
-> ((a, a) -> Int)
-> Ix a
$crange :: (Node, Node) -> [Node]
range :: (Node, Node) -> [Node]
$cindex :: (Node, Node) -> Node -> Int
index :: (Node, Node) -> Node -> Int
$cunsafeIndex :: (Node, Node) -> Node -> Int
unsafeIndex :: (Node, Node) -> Node -> Int
$cinRange :: (Node, Node) -> Node -> Bool
inRange :: (Node, Node) -> Node -> Bool
$crangeSize :: (Node, Node) -> Int
rangeSize :: (Node, Node) -> Int
$cunsafeRangeSize :: (Node, Node) -> Int
unsafeRangeSize :: (Node, Node) -> Int
Ix)