Skip to content

Instantly share code, notes, and snippets.

@eric-corumdigital
Last active March 13, 2019 20:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eric-corumdigital/dc10c08359e5a77dcaff04ffa12561ae to your computer and use it in GitHub Desktop.
Save eric-corumdigital/dc10c08359e5a77dcaff04ffa12561ae to your computer and use it in GitHub Desktop.
Lattices in PureScript
foreign import kind Semilattice
foreign import data Meet ∷ Semilattice
foreign import data Join ∷ Semilattice
data SemilatticeProxy (s ∷ Semilattice) = SemilatticeProxy
class Semilattice (x ∷ Semilattice) a where
marry ∷ ∀ proxy. proxy x → a → a → a
--
class Semilattice x a ⇐ BoundedSemilattice (x ∷ Semilattice) a where
boundary ∷ ∀ proxy. proxy x → a
--
class (Semilattice Meet a, Semilattice Join a) ⇐ Lattice a
class (BoundedSemilattice Meet a, BoundedSemilattice Join a) ⇐ BoundedLattice a
join ∷ ∀ a. Semilattice Join a ⇒ a → a → a
join = marry (SemilatticeProxy ∷ SemilatticeProxy Join)
meet ∷ ∀ a. Semilattice Meet a ⇒ a → a → a
meet = marry (SemilatticeProxy ∷ SemilatticeProxy Meet)
bottom ∷ ∀ a. BoundedSemilattice Join a ⇒ a
bottom = boundary (SemilatticeProxy ∷ SemilatticeProxy Join)
top ∷ ∀ a. BoundedSemilattice Meet a ⇒ a
top = boundary (SemilatticeProxy ∷ SemilatticeProxy Meet)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment