HasCallStack constraint for maximum in Prelude?
Todd Wilson via Haskell-Cafe <[email protected]> Sat, 24 Jan 2026 13:22:53 -0800
| Newsgroups | gmane.comp.lang.haskell.cafe |
|---|---|
| Message-ID | <CA+-99oL1AiPtbbiAtakHz1xg+tp0TQ6QNzvb2=Xj_nY4Dx+uiw@mail.gmail.com> |
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 -- [email protected] To (un)subscribe, modify options or view archives go to: Only members subscribed via the mailman list are allowed to post.