haskellari / lattices

Fine-grained lattice primitives for Haskell
BSD 3-Clause "New" or "Revised" License
35 stars 15 forks source link

Either as a lattice, Maybe as a lattice #98

Closed erykciepiela closed 4 years ago

erykciepiela commented 4 years ago

Add (Lattice a, Lattice b) => Lattice (Either a b) instance constructed by considering all minimal elements of b greater than all maximal elements of a Add Lattice a => Lattice (Maybe a) instance constructed by using Nothing as 0 element

phadej commented 4 years ago
phadej commented 4 years ago

To clarify, I'd not object having a type isomorphic to Either which is:

-- The name of this construction is escaping me atm
data SomeName a b = Upper a | Lower b

which your instance, but not for Either.

erykciepiela commented 4 years ago

Thanks for insightful comments. I think I get the point and general spirit of the library now. As for Either instance, in the spirit of Levitated and Dropped I would propose Stacked. Regarding Maybe I would propose conversion functions from Maybe to Dropped and Lifted. All these as part of the other PR #99.