
31 Oct
2009
31 Oct
'09
7:39 p.m.
the compare function for lists seems to be work like (leaving off class details):
compare [] [] = EQ compare [] _ = LT compare _ [] = GT compare (x:xt) (y:yt) = case x `compare` y of EQ -> xt `compare` yt _ -> x `compare` y
I poked around to see if I could find where this was defined in the spec or if it was an implementation specific thing (I need to be able to rely on this definition across implementations). I found this text in the report: -- Lists data [a] = [] | a : [a] deriving (Eq, Ord) -- Not legal Haskell; for illustration only Is this basically saying the same thing as my compare definition? Thanks Keith -- keithsheppard.name