holmes-0.3.0.1: Tools and combinators for solving constraint problems.

Data.JoinSemilattice.Intersect

Description

When we play games like Guess Who?, we start with a set of possible candidates, and eliminate subsets of them as the game progresses. The Intersect type works in a similar way: each cell stores a list of its potential values, and the merging operation takes the intersect of the current candidates and the new candidates.

Synopsis

# Documentation

newtype Intersect (x :: Type) Source #

A set type with intersection as the '(<>)' operation.

Constructors

 Intersect FieldstoHashSet :: HashSet x
Instances
 Source # Instance detailsDefined in Data.JoinSemilattice.Intersect Methodsfold :: Monoid m => Intersect m -> m #foldMap :: Monoid m => (a -> m) -> Intersect a -> m #foldr :: (a -> b -> b) -> b -> Intersect a -> b #foldr' :: (a -> b -> b) -> b -> Intersect a -> b #foldl :: (b -> a -> b) -> b -> Intersect a -> b #foldl' :: (b -> a -> b) -> b -> Intersect a -> b #foldr1 :: (a -> a -> a) -> Intersect a -> a #foldl1 :: (a -> a -> a) -> Intersect a -> a #toList :: Intersect a -> [a] #null :: Intersect a -> Bool #length :: Intersect a -> Int #elem :: Eq a => a -> Intersect a -> Bool #maximum :: Ord a => Intersect a -> a #minimum :: Ord a => Intersect a -> a #sum :: Num a => Intersect a -> a #product :: Num a => Intersect a -> a # Source # Instance detailsDefined in Data.JoinSemilattice.Class.Boolean Methods Source # Instance detailsDefined in Data.JoinSemilattice.Class.Eq Associated Types MethodseqR :: EqC' Intersect x => (Intersect x, Intersect x, Intersect Bool) -> (Intersect x, Intersect x, Intersect Bool) Source # Source # Instance detailsDefined in Data.JoinSemilattice.Class.Ord Associated Types MethodslteR :: OrdC Intersect x => (Intersect x, Intersect x, Intersect Bool) -> (Intersect x, Intersect x, Intersect Bool) Source # Source # Instance detailsDefined in Data.JoinSemilattice.Class.Mapping MethodsmapR :: (Intersectable x, Intersectable y) => (Maybe (x -> y), Maybe (y -> x)) -> (Intersect x, Intersect y) -> (Intersect x, Intersect y) Source # Source # Instance detailsDefined in Data.JoinSemilattice.Class.Zipping MethodszipWithR :: (Intersectable x, Intersectable y, Intersectable z) => (Maybe ((x, y) -> z), Maybe ((x, z) -> y), Maybe ((y, z) -> x)) -> (Intersect x, Intersect y, Intersect z) -> (Intersect x, Intersect y, Intersect z) Source # Source # Instance detailsDefined in Data.JoinSemilattice.Class.FlatMapping MethodsflatMapR :: (Intersectable x, Intersectable y) => (Maybe (x -> Intersect y), Maybe (Intersect y -> x)) -> (Intersect x, Intersect y) -> (Intersect x, Intersect y) Source # Eq x => Eq (Intersect x) Source # Instance detailsDefined in Data.JoinSemilattice.Intersect Methods(==) :: Intersect x -> Intersect x -> Bool #(/=) :: Intersect x -> Intersect x -> Bool # (Intersectable x, Fractional x) => Fractional (Intersect x) Source # Instance detailsDefined in Data.JoinSemilattice.Intersect Methods(/) :: Intersect x -> Intersect x -> Intersect x #recip :: Intersect x -> Intersect x # (Intersectable content, Num content) => Num (Intersect content) Source # Instance detailsDefined in Data.JoinSemilattice.Intersect Methods(+) :: Intersect content -> Intersect content -> Intersect content #(-) :: Intersect content -> Intersect content -> Intersect content #(*) :: Intersect content -> Intersect content -> Intersect content #negate :: Intersect content -> Intersect content #abs :: Intersect content -> Intersect content #signum :: Intersect content -> Intersect content #fromInteger :: Integer -> Intersect content # Ord x => Ord (Intersect x) Source # Instance detailsDefined in Data.JoinSemilattice.Intersect Methodscompare :: Intersect x -> Intersect x -> Ordering #(<) :: Intersect x -> Intersect x -> Bool #(<=) :: Intersect x -> Intersect x -> Bool #(>) :: Intersect x -> Intersect x -> Bool #(>=) :: Intersect x -> Intersect x -> Bool #max :: Intersect x -> Intersect x -> Intersect x #min :: Intersect x -> Intersect x -> Intersect x # Show x => Show (Intersect x) Source # Instance detailsDefined in Data.JoinSemilattice.Intersect MethodsshowsPrec :: Int -> Intersect x -> ShowS #show :: Intersect x -> String #showList :: [Intersect x] -> ShowS # (Eq content, Hashable content) => Semigroup (Intersect content) Source # Instance detailsDefined in Data.JoinSemilattice.Intersect Methods(<>) :: Intersect content -> Intersect content -> Intersect content #sconcat :: NonEmpty (Intersect content) -> Intersect content #stimes :: Integral b => b -> Intersect content -> Intersect content # Intersectable content => Monoid (Intersect content) Source # Instance detailsDefined in Data.JoinSemilattice.Intersect Methodsmempty :: Intersect content #mappend :: Intersect content -> Intersect content -> Intersect content #mconcat :: [Intersect content] -> Intersect content # Hashable x => Hashable (Intersect x) Source # Instance detailsDefined in Data.JoinSemilattice.Intersect MethodshashWithSalt :: Int -> Intersect x -> Int #hash :: Intersect x -> Int # Intersectable x => Input (Intersect x) Source # Instance detailsDefined in Data.JoinSemilattice.Intersect Associated Typestype Raw (Intersect x) :: Type Source # Methodsfrom :: Applicative m => Int -> [Raw (Intersect x)] -> Config m (Intersect x) Source # (Bounded x, Enum x, Ord x, Hashable x) => Merge (Intersect x) Source # Instance detailsDefined in Data.JoinSemilattice.Class.Merge Methods(<<-) :: Intersect x -> Intersect x -> Result (Intersect x) Source # (Bounded x, Enum x, Ord x, Hashable x, Num x) => SumR (Intersect x) Source # Instance detailsDefined in Data.JoinSemilattice.Class.Sum MethodsaddR :: (Intersect x, Intersect x, Intersect x) -> (Intersect x, Intersect x, Intersect x) Source # (Bounded x, Enum x, Ord x, Hashable x, Integral x) => IntegralR (Intersect x) Source # Instance detailsDefined in Data.JoinSemilattice.Class.Integral MethodsdivModR :: (Intersect x, Intersect x, Intersect x, Intersect x) -> (Intersect x, Intersect x, Intersect x, Intersect x) Source # (Bounded x, Enum x, Ord x, Fractional x, Hashable x) => FractionalR (Intersect x) Source # Instance detailsDefined in Data.JoinSemilattice.Class.Fractional MethodsmultiplyR :: (Intersect x, Intersect x, Intersect x) -> (Intersect x, Intersect x, Intersect x) Source # (Bounded x, Enum x, Ord x, Hashable x, Num x) => AbsR (Intersect x) Source # Instance detailsDefined in Data.JoinSemilattice.Class.Abs MethodsabsR :: (Intersect x, Intersect x) -> (Intersect x, Intersect x) Source # type EqC Intersect Source # Instance detailsDefined in Data.JoinSemilattice.Class.Eq type OrdC Intersect Source # Instance detailsDefined in Data.JoinSemilattice.Class.Ord type OrdC Intersect type Raw (Intersect x) Source # Instance detailsDefined in Data.JoinSemilattice.Intersect type Raw (Intersect x) = x

class (Bounded content, Enum content, Ord content, Hashable content) => Intersectable content Source #

Instances
 (Bounded content, Enum content, Ord content, Hashable content) => Intersectable content Source # Instance detailsDefined in Data.JoinSemilattice.Intersect Source # Instance detailsDefined in Data.JoinSemilattice.Class.Mapping MethodsmapR :: (Intersectable x, Intersectable y) => (Maybe (x -> y), Maybe (y -> x)) -> (Intersect x, Intersect y) -> (Intersect x, Intersect y) Source # Source # Instance detailsDefined in Data.JoinSemilattice.Class.Zipping MethodszipWithR :: (Intersectable x, Intersectable y, Intersectable z) => (Maybe ((x, y) -> z), Maybe ((x, z) -> y), Maybe ((y, z) -> x)) -> (Intersect x, Intersect y, Intersect z) -> (Intersect x, Intersect y, Intersect z) Source # Source # Instance detailsDefined in Data.JoinSemilattice.Class.FlatMapping MethodsflatMapR :: (Intersectable x, Intersectable y) => (Maybe (x -> Intersect y), Maybe (Intersect y -> x)) -> (Intersect x, Intersect y) -> (Intersect x, Intersect y) Source #

lift2 :: (Intersectable this, Intersectable that, Intersectable result) => (this -> that -> result) -> Intersect this -> Intersect that -> Intersect result Source #

fromList :: (Eq x, Hashable x) => [x] -> Intersect x Source #

Create an Intersect from a list of candidates.

toList :: (Bounded x, Enum x, Eq x) => Intersect x -> [x] Source #

Return a list of candidates stored within an Intersect.

decided :: (Applicative m, Intersectable x) => (x -> m ()) -> Intersect x -> m () Source #

Run an action only if a single candidate remains.

delete :: Intersectable x => x -> Intersect x -> Intersect x Source #

Delete a candidate from an Intersect.

except :: Intersectable x => Intersect x -> Intersect x Source #

Return an Intersect of all possible candidates except those in the given Intersect. The Intersect of all candidates is assumed to be mempty.

filter :: (x -> Bool) -> Intersect x -> Intersect x Source #

Filter an Intersect with a predicate.

fromSet :: (Eq x, Hashable x) => Set x -> Intersect x Source #

Convert a Set to an Intersect.

map :: (Eq y, Hashable y) => (x -> y) -> Intersect x -> Intersect y Source #

Map over an Intersect with a given function.

singleton :: Hashable x => x -> Intersect x Source #

Create a singleton Intersect.

size :: Intersectable x => Intersect x -> Int Source #

Count the candidates in an Intersect.

toSet :: Ord x => Intersect x -> Set x Source #

Convert an Intersect to a Set.

union :: Intersectable x => Intersect x -> Intersect x -> Intersect x Source #

Merge two Intersect values with set union.

using :: (Applicative m, Intersectable x) => [Intersect x] -> Config m (Intersect x) Source #

Produce a Config with the given initial value, where the refine function just tries each remaining candidate as a singleton.