typelevel / typelevel/cats

Split out ComplementedLattice from Heyting typeclass?

Open
#4,429 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Scala
Stars
5.5k
Forks
1.2k
Avg merge
2d 10h
Merged PRs (30d)
5

Description

(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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with algebra-core/src/main/scala/algebra/lattice/Heyting.scala and inspect the existing complement and imp methods in the Heyting typeclass. Compare the proposed ComplementedLattice abstraction with the linked lattice hierarchy and determine whether the API should separate the operations; done means reaching and documenting a settled design decision.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
api
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.