{-# LANGUAGE ScopedTypeVariables #-}
module Props.Internal.Links
( disjoint
, equal
, require
) where
import qualified Data.Set as S
import Props.Internal.PropT
disjoint :: forall a m. (Monad m, Ord a) => PVar S.Set a -> PVar S.Set a -> PropT m ()
disjoint a b = do
constrain a b disj
constrain b a disj
where
disj :: a -> S.Set a -> S.Set a
disj x xs = S.delete x xs
equal :: forall a m. (Monad m, Ord a) => PVar S.Set a -> PVar S.Set a -> PropT m ()
equal a b = do
constrain a b eq
constrain b a eq
where
eq :: a -> S.Set a -> S.Set a
eq x xs | x `S.member` xs = S.singleton x
| otherwise = S.empty
require :: Monad m => (a -> b -> Bool) -> PVar S.Set a -> PVar S.Set b -> PropT m ()
require f a b = do
constrain a b (S.filter . f)