Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split out ComplementedLattice from Heyting typeclass? #4429

Open
benhutchison opened this issue Apr 18, 2023 · 0 comments
Open

Split out ComplementedLattice from Heyting typeclass? #4429

benhutchison opened this issue Apr 18, 2023 · 0 comments

Comments

@benhutchison
Copy link
Member

(Ok I'm being slightly tongue in cheek, but..) IMO it's an unfortunate accident of history that the lattice algebra hierarchy ended up in a ecosystem-anchor library like Cats.

On one hand, it begs to become the butt of jokes. A workmate used to ask if anyone had "designed any lattices lately?".

OTOH it means that evolving the lattice typeclasses becomes a more heavyweight change than in Spire or another more obscure location.

The Heyting typeclass introduced two new, independent abstract methods, complement and imp (implication).

https://github.com/typelevel/cats/blob/main/algebra-core/src/main/scala/algebra/lattice/Heyting.scala#L64-L65

Introducing two distinct abstract operations in a single TC may be a design smell. Is there a weaker form with just one?

Yes, an algebra that has just complement without imp is called a Complemented Lattice.

Why does it matter? Well, a datatype for proper fraction, a value between [0, 1], could implement ComplementedLattice and complement is useful. But I can't see a sensible implementation for imp that would get used; that operator seems to belong in discrete logics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant