Skip to content

Commit

Permalink
feat(lattices): make unit () a point lattice (#793)
Browse files Browse the repository at this point in the history
  • Loading branch information
MingweiSamuel committed Jun 29, 2023
1 parent dc99c02 commit 016abee
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lattices/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ Take a look at the [`lattice` rustdocs](https://hydro-project.github.io/hydroflo
* [`Seq<Lat>`] - growing `Vec` of nested lattices, like `MapUnion<<usize, Lat>>` but without missing entries.
* [`DomPair<LatKey, LatVal>`]* - a versioned pair where the `LatKey` dominates the `LatVal`.
* [`Conflict<T>`]* - adds a "conflict" top to domain `T`. Merging inequal `T`s results in top.
* [`Point<T>`]* - a single "point lattice" value which cannot be merged with any inequal value.
* [`Point<T, *>`]* - a single "point lattice" value which cannot be merged with any inequal value.
* [`()`](https://doc.rust-lang.org/std/primitive.unit.html) - the "unit" lattice, a "point lattice" with unit `()` as the only value in the domain.

*Special implementations which do not obey all lattice properties but are still useful under
certain circumstances.
Expand Down
1 change: 1 addition & 0 deletions lattices/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ mod point;
mod seq;
pub mod set_union;
pub mod test;
mod unit;
mod with_bot;
mod with_top;

Expand Down
27 changes: 27 additions & 0 deletions lattices/src/unit.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
use crate::{IsBot, IsTop, LatticeFrom, LatticeOrd, Merge};

impl Merge<()> for () {
fn merge(&mut self, _other: ()) -> bool {
false
}
}

impl LatticeOrd for () {}

impl LatticeFrom<()> for () {
fn lattice_from(other: ()) -> Self {
other
}
}

impl IsBot for () {
fn is_bot(&self) -> bool {
true
}
}

impl IsTop for () {
fn is_top(&self) -> bool {
true
}
}

0 comments on commit 016abee

Please sign in to comment.