holmes-0.3.2.0: Tools and combinators for solving constraint problems.
Copyright(c) Tom Harding 2020
LicenseMIT
Safe HaskellNone
LanguageHaskell2010

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 

Fields

Instances

Instances details
Foldable Intersect Source # 
Instance details

Defined in Data.JoinSemilattice.Intersect

Methods

fold :: Monoid m => Intersect m -> m #

foldMap :: Monoid m => (a -> m) -> Intersect a -> 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 #

BooleanR Intersect Source # 
Instance details

Defined in Data.JoinSemilattice.Class.Boolean

EqR Intersect Source # 
Instance details

Defined in Data.JoinSemilattice.Class.Eq

Associated Types

type EqC Intersect :: Type -> Constraint Source #

OrdR Intersect Source # 
Instance details

Defined in Data.JoinSemilattice.Class.Ord

Associated Types

type OrdC Intersect :: Type -> Constraint Source #

Mapping Intersect Intersectable Source # 
Instance details

Defined in Data.JoinSemilattice.Class.Mapping

Methods

mapR :: (Intersectable x, Intersectable y) => (Maybe (x -> y), Maybe (y -> x)) -> (Intersect x, Intersect y) -> (Intersect x, Intersect y) Source #

Zipping Intersect Intersectable Source # 
Instance details

Defined in Data.JoinSemilattice.Class.Zipping

Methods

zipWithR :: (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 #

Lifting Intersect Intersectable Source # 
Instance details

Defined in Data.JoinSemilattice.Class.Lifting

Methods

lift' :: Intersectable x => x -> Intersect x Source #

FlatMapping Intersect Intersectable Source # 
Instance details

Defined in Data.JoinSemilattice.Class.FlatMapping

Methods

flatMapR :: (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 details

Defined in Data.JoinSemilattice.Intersect

Methods

(==) :: Intersect x -> Intersect x -> Bool #

(/=) :: Intersect x -> Intersect x -> Bool #

(Intersectable x, Fractional x) => Fractional (Intersect x) Source # 
Instance details

Defined in Data.JoinSemilattice.Intersect

(Intersectable content, Num content) => Num (Intersect content) Source # 
Instance details

Defined 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 details

Defined in Data.JoinSemilattice.Intersect

Show x => Show (Intersect x) Source # 
Instance details

Defined in Data.JoinSemilattice.Intersect

(Eq content, Hashable content) => Semigroup (Intersect content) Source # 
Instance details

Defined 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 details

Defined in Data.JoinSemilattice.Intersect

Methods

mempty :: Intersect content #

mappend :: Intersect content -> Intersect content -> Intersect content #

mconcat :: [Intersect content] -> Intersect content #

Hashable x => Hashable (Intersect x) Source # 
Instance details

Defined in Data.JoinSemilattice.Intersect

Methods

hashWithSalt :: Int -> Intersect x -> Int #

hash :: Intersect x -> Int #

Intersectable x => Input (Intersect x) Source # 
Instance details

Defined in Data.JoinSemilattice.Intersect

Associated Types

type Raw (Intersect x) Source #

Methods

from :: forall (m :: Type -> Type). Applicative m => Int -> [Raw (Intersect x)] -> Config m (Intersect x) Source #

(Bounded x, Enum x, Ord x, Hashable x) => Merge (Intersect x) Source # 
Instance details

Defined in Data.JoinSemilattice.Class.Merge

Methods

(<<-) :: Intersect x -> Intersect x -> Result (Intersect x) Source #

(Intersectable x, Num x) => SumR (Intersect x) Source # 
Instance details

Defined in Data.JoinSemilattice.Class.Sum

(Bounded x, Enum x, Ord x, Hashable x, Integral x) => IntegralR (Intersect x) Source # 
Instance details

Defined in Data.JoinSemilattice.Class.Integral

(Bounded x, Enum x, Ord x, Fractional x, Hashable x) => FractionalR (Intersect x) Source # 
Instance details

Defined in Data.JoinSemilattice.Class.Fractional

(Bounded x, Enum x, Ord x, Hashable x, Num x) => AbsR (Intersect x) Source # 
Instance details

Defined in Data.JoinSemilattice.Class.Abs

Methods

absR :: (Intersect x, Intersect x) -> (Intersect x, Intersect x) Source #

type EqC Intersect Source # 
Instance details

Defined in Data.JoinSemilattice.Class.Eq

type OrdC Intersect Source # 
Instance details

Defined in Data.JoinSemilattice.Class.Ord

type Raw (Intersect x) Source # 
Instance details

Defined in Data.JoinSemilattice.Intersect

type Raw (Intersect x) = x

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

Instances

Instances details
(Bounded content, Enum content, Ord content, Hashable content) => Intersectable content Source # 
Instance details

Defined in Data.JoinSemilattice.Intersect

Mapping Intersect Intersectable Source # 
Instance details

Defined in Data.JoinSemilattice.Class.Mapping

Methods

mapR :: (Intersectable x, Intersectable y) => (Maybe (x -> y), Maybe (y -> x)) -> (Intersect x, Intersect y) -> (Intersect x, Intersect y) Source #

Zipping Intersect Intersectable Source # 
Instance details

Defined in Data.JoinSemilattice.Class.Zipping

Methods

zipWithR :: (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 #

Lifting Intersect Intersectable Source # 
Instance details

Defined in Data.JoinSemilattice.Class.Lifting

Methods

lift' :: Intersectable x => x -> Intersect x Source #

FlatMapping Intersect Intersectable Source # 
Instance details

Defined in Data.JoinSemilattice.Class.FlatMapping

Methods

flatMapR :: (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.