Why minimum (1, 2) is 2 in Haskell?
My test result in GHCi,
GHCi, version 8.2.1: http://www.haskell.org/ghc/ :? for help
Prelude> minimum (1, 2)
2
Shouldn't it return 1?
The type of minimum is
(Ord a, Foldable t) => t a -> a
The Foldable instance for pairs refers only to the second element of the pair, which you can see with toList:
toList (1,2)
> [2]
the minimum element in that collection is 2.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With