While we are on it. Add `x-partial` to `List.maximum/minimum` and `Foldable.maximum/minimum` and point to Foldable1 variants.

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).

- Oleg

On 3/23/26 02:40, Andrew Lelechenko wrote:
Hi Todd,

You can find some discussion at https://mail.haskell.org/pipermail/libraries/2021-May/031246.html.

It’s tricky: a monomorphic GHC.List.maximum :: [a] -> a got HasCallStack, while a polymorphic one Data.Foldable.maximum :: Foldable t => t a -> a didn’t. The reason for this was a concern that adding HasCallStack to class methods might have adverse performance consequences. So out of abundance of caution and to get at least something done, the proposal targeted only monomorphic partial functions. I think an enthusiastic proposer, willing to benchmark it, could add HasCallStack to polymorphic partial functions as well (I would personally be in favour).

Also, there is a total Data.Foldable1.maximum at https://hackage-content.haskell.org/package/base-4.22.0.0/docs/Data-Foldable1.html#t:Foldable1.

Best regards,
Andrew

On 22 Mar 2026, at 23:48, Todd Wilson via Haskell-Cafe <haskell-cafe@haskell.org> wrote:

I sent this two months ago but received no response. One of my students asked me this, and I didn't know how to answer, so I asked here. Did it slip in under the radar? Did I ask it in the wrong forum? Or was everyone waiting for someone else to answer? :-)

Todd Wilson
Department of Computer Science
California State University, Fresno

On Sat, Jan 24, 2026 at 1:22 PM Todd Wilson <twilson@csufresno.edu> wrote:
Should maximum and minimum have HasCallStack constraints like head and tail do?

ghci> :type head
head :: GHC.Stack.Types.HasCallStack => [a] -> a
ghci> head []
*** Exception: Prelude.head: empty list
CallStack (from HasCallStack):
  error, called at libraries/base/GHC/List.hs:1646:3 in base:GHC.List
  errorEmptyList, called at libraries/base/GHC/List.hs:85:11 in base:GHC.List
  badHead, called at libraries/base/GHC/List.hs:81:28 in base:GHC.List
  head, called at <interactive>:8:1 in interactive:Ghci1
ghci> :type maximum
maximum :: (Foldable t, Ord a) => t a -> a
ghci> maximum []
*** Exception: Prelude.maximum: empty list
CallStack (from HasCallStack):
  error, called at libraries/base/GHC/List.hs:1646:3 in base:GHC.List
  errorEmptyList, called at libraries/base/GHC/List.hs:717:28 in base:GHC.List
  maximum, called at libraries/base/Data/Foldable.hs:745:15 in base:Data.Foldable

Todd Wilson
_______________________________________________
Haskell-Cafe mailing list -- haskell-cafe@haskell.org
To (un)subscribe, modify options or view archives go to:
Only members subscribed via the mailman list are allowed to post.


_______________________________________________
Haskell-Cafe mailing list -- haskell-cafe@haskell.org
To (un)subscribe, modify options or view archives go to:
Only members subscribed via the mailman list are allowed to post.