Re: HasCallStack constraint for maximum in Prelude?

Olaf Klinke via Haskell-Cafe <[email protected]> Wed, 25 Mar 2026 11:19:20 +0100
Newsgroups gmane.comp.lang.haskell.cafe
Message-ID <[email protected]>
> Adding that warning won't affect performance, but it would guide
> people
> to never use them (Especially Foldable variant; its type is wrong -
> it
> would make some sense with Bounded - if Bounded were related to Ord).
> 

For (Bounded a, Ord a) one should replace maximum by an ordinary fold,
given a suitable newtype wrapper with a Monoid instance, e.g. 

(Ord a, Bounded a) => Monoid (Data.Semigroup.Max a)

In the past I've also used custom newtypes if e.g. I knew all values
were non-negative and the least value I cared about was zero. 

-- Olaf
_______________________________________________
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.