Last active
March 13, 2019 20:06
-
-
Save eric-corumdigital/dc10c08359e5a77dcaff04ffa12561ae to your computer and use it in GitHub Desktop.
Lattices in PureScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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