Monoid mempty in pattern matching
问题 I tried to write a generalized maximum function similar to the one in Prelude . My first naiv approach looked like this: maximum' :: (F.Foldable a, Ord b) => a b -> Maybe b maximum' mempty = Nothing maximum' xs = Just $ F.foldl1 max xs However, when I test it it always returns Nothing regardless of the input: > maximum' [1,2,3] > Nothing Now I wonder whether it's possible to obtain the empty value of a Monoid type instance. A test function I wrote works correctly: getMempty :: (Monoid a) => a