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