holmes-0.1.0.1: 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
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 #

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 #

Mapping Intersect Intersectable Source # 
Instance details

Defined in Data.JoinSemilattice.Class.Mapping

Methods

mapR :: (Intersectable x, Intersectable y) => ((x, y) -> (x, y)) -> (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) => ((x, y, z) -> (x, y, z)) -> (Intersect x, Intersect y, Intersect z) -> (Intersect x, Intersect y, Intersect z) Source #

FlatMapping Intersect Intersectable Source # 
Instance details

Defined in Data.JoinSemilattice.Class.FlatMapping

Methods

flatMapR :: (Intersectable x, Intersectable y) => ((x, Intersect y) -> (x, Intersect y)) -> (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) :: Type Source #

Methods

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

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

Defined in Data.JoinSemilattice.Class.Merge

Methods

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

(Bounded x, Enum x, Eq x, Hashable x, Num x) => SumR (Intersect x) Source # 
Instance details

Defined in Data.JoinSemilattice.Class.Sum

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

Defined in Data.JoinSemilattice.Class.Integral

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

Defined in Data.JoinSemilattice.Class.Fractional

BooleanR (Intersect Bool) Source # 
Instance details

Defined in Data.JoinSemilattice.Class.Boolean

(Bounded x, Enum x, Eq 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 #

(Bounded x, Enum x, Eq x, Hashable x) => EqR (Intersect x) (Intersect Bool) Source # 
Instance details

Defined in Data.JoinSemilattice.Class.Eq

(Bounded x, Enum x, Hashable x, Ord x) => OrdR (Intersect x) (Intersect Bool) 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, Eq content, Hashable content) => Intersectable content Source #

Instances
(Bounded content, Enum content, Eq 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) => ((x, y) -> (x, y)) -> (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) => ((x, y, z) -> (x, y, z)) -> (Intersect x, Intersect y, Intersect z) -> (Intersect x, Intersect y, Intersect z) Source #

FlatMapping Intersect Intersectable Source # 
Instance details

Defined in Data.JoinSemilattice.Class.FlatMapping

Methods

flatMapR :: (Intersectable x, Intersectable y) => ((x, Intersect y) -> (x, Intersect y)) -> (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.

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.

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.