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, Ord 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
- fromSet :: (Eq x, Hashable x) => Set x -> Intersect x
- map :: (Eq y, Hashable y) => (x -> y) -> Intersect x -> Intersect y
- powerSet :: (Bounded x, Enum x, Hashable x, Ord x) => Intersect x -> Intersect (Intersect x)
- singleton :: Hashable x => x -> Intersect x
- size :: Intersectable x => Intersect x -> Int
- toSet :: Ord x => Intersect x -> Set x
- 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, Ord content, Hashable content) => Intersectable content Source #

#### Instances

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

Defined in Data.JoinSemilattice.Intersect | |

Mapping Intersect Intersectable Source # | |

Defined in Data.JoinSemilattice.Class.Mapping | |

Zipping Intersect Intersectable Source # | |

Defined in Data.JoinSemilattice.Class.Zipping 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 # | |

Defined in Data.JoinSemilattice.Class.Lifting lift' :: Intersectable x => x -> Intersect x 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.

powerSet :: (Bounded x, Enum x, Hashable x, Ord x) => Intersect x -> Intersect (Intersect x) Source #

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 #