Copyright | (c) Tom Harding 2020 |
---|---|
License | MIT |
Safe Haskell | None |
Language | Haskell2010 |
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
- newtype Intersect (x :: Type) = Intersect {}
- class (Bounded content, Enum content, Eq content, Hashable content) => Intersectable content
- lift2 :: (Intersectable this, Intersectable that, Intersectable result) => (this -> that -> result) -> Intersect this -> Intersect that -> Intersect result
- fromList :: (Eq x, Hashable x) => [x] -> Intersect x
- toList :: (Bounded x, Enum x, Eq x) => Intersect x -> [x]
- decided :: (Applicative m, Intersectable x) => (x -> m ()) -> Intersect x -> m ()
- delete :: Intersectable x => x -> Intersect x -> Intersect x
- except :: Intersectable x => Intersect x -> Intersect x
- filter :: (x -> Bool) -> Intersect x -> Intersect x
- map :: (Eq y, Hashable y) => (x -> y) -> Intersect x -> Intersect y
- singleton :: Hashable x => x -> Intersect x
- size :: Intersectable x => Intersect x -> Int
- union :: Intersectable x => Intersect x -> Intersect x -> Intersect x
- using :: (Applicative m, Intersectable x) => [Intersect x] -> Config m (Intersect x)
Documentation
newtype Intersect (x :: Type) Source #
A set type with intersection as the '(<>)' operation.
Instances
class (Bounded content, Enum content, Eq content, Hashable content) => Intersectable content Source #
Instances
(Bounded content, Enum content, Eq content, Hashable content) => Intersectable content Source # | |
Defined in Data.JoinSemilattice.Intersect | |
Mapping Intersect Intersectable Source # | |
Defined in Data.JoinSemilattice.Class.Mapping mapR :: (Intersectable x, Intersectable y) => ((x, y) -> (x, y)) -> (Intersect x, Intersect y) -> (Intersect x, Intersect y) Source # | |
Zipping Intersect Intersectable Source # | |
Defined in Data.JoinSemilattice.Class.Zipping 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 # | |
Defined in Data.JoinSemilattice.Class.FlatMapping |
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
.
map :: (Eq y, Hashable y) => (x -> y) -> Intersect x -> Intersect y Source #
Map over an Intersect
with a given function.
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 #