{-# Language TypeFamilies #-}
{-# Language TypeApplications #-}
module Data.Connection.Property where
import Data.Prd
import Data.Connection
import Prelude hiding (Num(..),Ord(..))
import qualified Test.Function.Idempotent as Prop
import qualified Test.Function.Invertible as Prop
import qualified Test.Function.Monotone as Prop
connection :: Prd a => Prd b => Conn a b -> a -> b -> Bool
connection (Conn f g) = Prop.adjoint_on (<=) (<=) f g
closed :: Prd a => Prd b => Conn a b -> a -> Bool
closed (Conn f g) = Prop.invertible_on (>=) f g
closed' :: Prd a => Prd b => Trip a b -> a -> Bool
closed' t x = closed (tripl t) x && kernel (tripr t) x
kernel :: Prd a => Prd b => Conn a b -> b -> Bool
kernel (Conn f g) = Prop.invertible_on (<=) g f
kernel' :: Prd a => Prd b => Trip a b -> b -> Bool
kernel' t x = closed (tripr t) x && kernel (tripl t) x
monotoner :: Prd a => Prd b => Conn a b -> b -> b -> Bool
monotoner (Conn _ g) = Prop.monotone_on (<=) (<=) g
monotonel :: Prd a => Prd b => Conn a b -> a -> a -> Bool
monotonel (Conn f _) = Prop.monotone_on (<=) (<=) f
idempotent_unit :: Prd a => Prd b => Conn a b -> a -> Bool
idempotent_unit conn = Prop.idempotent_on (=~) $ unit conn
idempotent_counit :: Prd a => Prd b => Conn a b -> b -> Bool
idempotent_counit conn = Prop.idempotent_on (=~) $ counit conn
projectivel :: Prd a => Prd b => Conn a b -> a -> Bool
projectivel conn@(Conn f _) = Prop.projective_on (=~) f $ counit conn
projectiver :: Prd a => Prd b => Conn a b -> b -> Bool
projectiver conn@(Conn _ g) = Prop.projective_on (=~) g $ unit conn