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 { TransitiveRelation a -> Relation a
fromTransitive :: Relation a }
deriving (String -> TransitiveRelation a
(String -> TransitiveRelation a) -> IsString (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 -> ()
(TransitiveRelation a -> ()) -> NFData (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
(TransitiveRelation a
-> TransitiveRelation a -> TransitiveRelation a)
-> (TransitiveRelation a
-> TransitiveRelation a -> TransitiveRelation a)
-> (TransitiveRelation a
-> TransitiveRelation a -> TransitiveRelation a)
-> (TransitiveRelation a -> TransitiveRelation a)
-> (TransitiveRelation a -> TransitiveRelation a)
-> (TransitiveRelation a -> TransitiveRelation a)
-> (Integer -> TransitiveRelation a)
-> Num (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 = TransitiveRelation a -> Relation a
forall a. Ord a => TransitiveRelation a -> Relation a
toRelation TransitiveRelation a
x Relation a -> Relation a -> Bool
forall a. Eq a => a -> a -> Bool
== TransitiveRelation a -> Relation a
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 = Relation a -> Relation a -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (TransitiveRelation a -> Relation a
forall a. Ord a => TransitiveRelation a -> Relation a
toRelation TransitiveRelation a
x) (TransitiveRelation a -> Relation a
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 = Relation a -> String
forall a. Show a => a -> String
show (Relation a -> String)
-> (TransitiveRelation a -> Relation a)
-> TransitiveRelation a
-> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TransitiveRelation a -> Relation a
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 = Relation a -> TransitiveRelation a
forall a. Relation a -> TransitiveRelation a
TransitiveRelation Relation a
forall a. Relation a
empty
vertex :: Vertex (TransitiveRelation a) -> TransitiveRelation a
vertex = Relation a -> TransitiveRelation a
forall a. Relation a -> TransitiveRelation a
TransitiveRelation (Relation a -> TransitiveRelation a)
-> (a -> Relation a) -> a -> TransitiveRelation a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Relation a
forall a. a -> Relation a
vertex
overlay :: TransitiveRelation a
-> TransitiveRelation a -> TransitiveRelation a
overlay TransitiveRelation a
x TransitiveRelation a
y = Relation a -> TransitiveRelation a
forall a. Relation a -> TransitiveRelation a
TransitiveRelation (Relation a -> TransitiveRelation a)
-> Relation a -> TransitiveRelation a
forall a b. (a -> b) -> a -> b
$ TransitiveRelation a -> Relation a
forall a. TransitiveRelation a -> Relation a
fromTransitive TransitiveRelation a
x Relation a -> Relation a -> Relation a
forall a. Ord a => Relation a -> Relation a -> Relation a
`overlay` TransitiveRelation a -> Relation a
forall a. TransitiveRelation a -> Relation a
fromTransitive TransitiveRelation a
y
connect :: TransitiveRelation a
-> TransitiveRelation a -> TransitiveRelation a
connect TransitiveRelation a
x TransitiveRelation a
y = Relation a -> TransitiveRelation a
forall a. Relation a -> TransitiveRelation a
TransitiveRelation (Relation a -> TransitiveRelation a)
-> Relation a -> TransitiveRelation a
forall a b. (a -> b) -> a -> b
$ TransitiveRelation a -> Relation a
forall a. TransitiveRelation a -> Relation a
fromTransitive TransitiveRelation a
x Relation a -> Relation a -> Relation a
forall a. Ord a => Relation a -> Relation a -> Relation a
`connect` TransitiveRelation a -> Relation a
forall a. TransitiveRelation a -> Relation a
fromTransitive TransitiveRelation a
y
instance Ord a => C.Transitive (TransitiveRelation a)
fromRelation :: Relation a -> TransitiveRelation a
fromRelation :: Relation a -> TransitiveRelation a
fromRelation = Relation a -> TransitiveRelation a
forall a. Relation a -> TransitiveRelation a
TransitiveRelation
toRelation :: Ord a => TransitiveRelation a -> Relation a
toRelation :: TransitiveRelation a -> Relation a
toRelation = Relation a -> Relation a
forall a. Ord a => Relation a -> Relation a
transitiveClosure (Relation a -> Relation a)
-> (TransitiveRelation a -> Relation a)
-> TransitiveRelation a
-> Relation a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TransitiveRelation a -> Relation a
forall a. TransitiveRelation a -> Relation a
fromTransitive