3 ms·
So the article first states a mathematical definition: > A bounded lattice is a mathematical structure that has a least element (bot), a greatest element (top)
by nandemo 15y ago
So the article first states a mathematical definition:
> A bounded lattice is a mathematical structure that has a least element (bot), a greatest element (top)
And then proceeds to define a typeclass that does not satisfy the definition:
instance (Ord k, Lattice a) => Lattice (Map k a)
where top = error $ "Cannot be represented.
:-(
You can't even fix the definition of top, since union of arbitrary Maps is not bounded, e.g. there is no finite Map String foo (map with String keys) that is a superset of every Map String foo.
You could change Lattice to a weaker structure, but I think it would be better to present a simpler typeclass like Show or Ord.