Re: HasCallStack constraint for maximum in Prelude?
Olaf Klinke via Haskell-Cafe <[email protected]> Wed, 25 Mar 2026 18:37:45 +0100
| Newsgroups | gmane.comp.lang.haskell.cafe |
|---|---|
| Message-ID | <[email protected]> |
Mathematically, the least amount of structure needed for maximum and minimum is a bounded semilattice, which in contrast to the Bounded class requires only one bound to exist. Such structures are defined for example in the semilattices [1] and lattices [2] packages. The semilattices package provides the instances (Lower a, Join a) => Monoid (Joining a) (Upper a, Meet a) => Monoid (Meeting a) whereas the lattices package provides the BoundedJoinSemilattice and BoundedMeetSemilattice classes and the functions joins :: (BoundedJoinSemiLattice a, Foldable f) => f a -> a meets :: (BoundedMeetSemiLattice a, Foldable f) => f a -> a joins1 :: (Lattice a, Foldable1 f) => f a -> a meets1 :: (Lattice a, Foldable1 f) => f a -> a as well as the wrappers Meet and Join with appropriate Monoid instances to recover the joins and meets functions via foldMap. Olaf [1] https://hackage.haskell.org/package/semilattices [2] https://hackage.haskell.org/package/lattices _______________________________________________ Haskell-Cafe mailing list -- [email protected] To (un)subscribe, modify options or view archives go to: Only members subscribed via the mailman list are allowed to post.