module Algebra.Graph.Relation.Transitive (
TransitiveRelation, fromRelation, toRelation
) where
import Algebra.Graph.Relation
import Control.DeepSeq
import Data.String
import qualified Algebra.Graph.Class as C
newtype TransitiveRelation a = TransitiveRelation { forall a. TransitiveRelation a -> Relation a
fromTransitive :: Relation a }
deriving (String -> TransitiveRelation a
forall a. IsString a => String -> TransitiveRelation a
forall a. (String -> a) -> IsString a
fromString :: String -> TransitiveRelation a
$cfromString :: forall a. IsString a => String -> TransitiveRelation a
IsString, TransitiveRelation a -> ()
forall a. NFData a => TransitiveRelation a -> ()
forall a. (a -> ()) -> NFData a
rnf :: TransitiveRelation a -> ()
$crnf :: forall a. NFData a => TransitiveRelation a -> ()
NFData, Integer -> TransitiveRelation a
TransitiveRelation a -> TransitiveRelation a
TransitiveRelation a
-> TransitiveRelation a -> TransitiveRelation a
forall a. (Ord a, Num a) => Integer -> TransitiveRelation a
forall a.
(Ord a, Num a) =>
TransitiveRelation a -> TransitiveRelation a
forall a.
(Ord a, Num a) =>
TransitiveRelation a
-> TransitiveRelation a -> TransitiveRelation a
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
fromInteger :: Integer -> TransitiveRelation a
$cfromInteger :: forall a. (Ord a, Num a) => Integer -> TransitiveRelation a
signum :: TransitiveRelation a -> TransitiveRelation a
$csignum :: forall a.
(Ord a, Num a) =>
TransitiveRelation a -> TransitiveRelation a
abs :: TransitiveRelation a -> TransitiveRelation a
$cabs :: forall a.
(Ord a, Num a) =>
TransitiveRelation a -> TransitiveRelation a
negate :: TransitiveRelation a -> TransitiveRelation a
$cnegate :: forall a.
(Ord a, Num a) =>
TransitiveRelation a -> TransitiveRelation a
* :: TransitiveRelation a
-> TransitiveRelation a -> TransitiveRelation a
$c* :: forall a.
(Ord a, Num a) =>
TransitiveRelation a
-> TransitiveRelation a -> TransitiveRelation a
- :: TransitiveRelation a
-> TransitiveRelation a -> TransitiveRelation a
$c- :: forall a.
(Ord a, Num a) =>
TransitiveRelation a
-> TransitiveRelation a -> TransitiveRelation a
+ :: TransitiveRelation a
-> TransitiveRelation a -> TransitiveRelation a
$c+ :: forall a.
(Ord a, Num a) =>
TransitiveRelation a
-> TransitiveRelation a -> TransitiveRelation a
Num)
instance Ord a => Eq (TransitiveRelation a) where
TransitiveRelation a
x == :: TransitiveRelation a -> TransitiveRelation a -> Bool
== TransitiveRelation a
y = forall a. Ord a => TransitiveRelation a -> Relation a
toRelation TransitiveRelation a
x forall a. Eq a => a -> a -> Bool
== forall a. Ord a => TransitiveRelation a -> Relation a
toRelation TransitiveRelation a
y
instance Ord a => Ord (TransitiveRelation a) where
compare :: TransitiveRelation a -> TransitiveRelation a -> Ordering
compare TransitiveRelation a
x TransitiveRelation a
y = forall a. Ord a => a -> a -> Ordering
compare (forall a. Ord a => TransitiveRelation a -> Relation a
toRelation TransitiveRelation a
x) (forall a. Ord a => TransitiveRelation a -> Relation a
toRelation TransitiveRelation a
y)
instance (Ord a, Show a) => Show (TransitiveRelation a) where
show :: TransitiveRelation a -> String
show = forall a. Show a => a -> String
show forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Ord a => TransitiveRelation a -> Relation a
toRelation
instance Ord a => C.Graph (TransitiveRelation a) where
type Vertex (TransitiveRelation a) = a
empty :: TransitiveRelation a
empty = forall a. Relation a -> TransitiveRelation a
TransitiveRelation forall a. Relation a
empty
vertex :: Vertex (TransitiveRelation a) -> TransitiveRelation a
vertex = forall a. Relation a -> TransitiveRelation a
TransitiveRelation forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. a -> Relation a
vertex
overlay :: TransitiveRelation a
-> TransitiveRelation a -> TransitiveRelation a
overlay TransitiveRelation a
x TransitiveRelation a
y = forall a. Relation a -> TransitiveRelation a
TransitiveRelation forall a b. (a -> b) -> a -> b
$ forall a. TransitiveRelation a -> Relation a
fromTransitive TransitiveRelation a
x forall a. Ord a => Relation a -> Relation a -> Relation a
`overlay` forall a. TransitiveRelation a -> Relation a
fromTransitive TransitiveRelation a
y
connect :: TransitiveRelation a
-> TransitiveRelation a -> TransitiveRelation a
connect TransitiveRelation a
x TransitiveRelation a
y = forall a. Relation a -> TransitiveRelation a
TransitiveRelation forall a b. (a -> b) -> a -> b
$ forall a. TransitiveRelation a -> Relation a
fromTransitive TransitiveRelation a
x forall a. Ord a => Relation a -> Relation a -> Relation a
`connect` forall a. TransitiveRelation a -> Relation a
fromTransitive TransitiveRelation a
y
instance Ord a => C.Transitive (TransitiveRelation a)
fromRelation :: Relation a -> TransitiveRelation a
fromRelation :: forall a. Relation a -> TransitiveRelation a
fromRelation = forall a. Relation a -> TransitiveRelation a
TransitiveRelation
toRelation :: Ord a => TransitiveRelation a -> Relation a
toRelation :: forall a. Ord a => TransitiveRelation a -> Relation a
toRelation = forall a. Ord a => Relation a -> Relation a
transitiveClosure forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. TransitiveRelation a -> Relation a
fromTransitive