maximum [] complains about an empty list

Neil Mitchell ndmitchell at gmail.com
Thu Nov 23 22:09:13 EST 2006


Hi,

In GHC:
Prelude> maximum []
*** Exception: Prelude.maximum: empty list

In Hugs:
Prelude> maximum []
Program error: pattern match failure: foldl1 (Ord_max instOrd_v29) []

Obviously this is because foldl1 is used to define maximum, but it
would be nice if the equation maximum [] = error "pattern match
failure in maximum" was issued, otherwise people might end up grepping
for foldl1 which doesn't ever occur in their code.

Thanks

Neil


More information about the Hugs-Bugs mailing list