リストやタプルも Eq クラス、 Ord クラスのインスタンスでそのまま内部まで同値判定、比較される。
class Eq a where (==) :: a -> a -> Bool (/=) :: a -> a -> Bool class Eq a => Ord a where compare :: a -> a -> Ordering (<) :: a -> a -> Bool (>=):: a -> a -> Bool (>) :: a -> a -> Bool (<=):: a -> a -> Bool max :: a -> a -> a min :: a -> a -> a
[[1,2,3],[4,5,6],[7,8,9]]==[[1,2,3],[4,5,6],[7,8,9]] -- => True [[1,2,3],[4,5,6],[7,8,9]]==[[1,2,3],[4,5,6],[7,8,10]] -- => False (3,"hello",[1,2,3])==(3,"hello",[1,2,3]) -- => True (3,"hello",[1,2,3])==(3,"hello",[1,2,4]) -- => False min (3,"hello") (3,"hell") -- => (3,"hell") max (3,"hello") (3,"hell") -- => (3,"hello") [[1,2,3],[4,5,6],[7,8,9]] < [[1,2,3],[4,5,6],[7,8,10]] -- => True [[1,2,3],[4,5,6],[7,8,9]] > [[1,2,3],[4,5,6],[7,8,10]] -- => False
凄い! と思ったら、Ruby も内部まで同値判定される。(比較は出来ない)