[Haskell-cafe] Learn You a Haskell for Great Good - a few doubts

Ozgur Akgun ozgurakgun at gmail.com
Fri Mar 4 16:50:18 CET 2011


On 4 March 2011 09:47, Karthick Gururaj <karthick.gururaj at gmail.com> wrote:

> I'm not able to still appreciate the choice of the default ordering order,
>

I don't know if this will help you appreciate the default or not, but just
to say this default is concordant with the auto-derived Ord instances.

data Tuple3 a b c = Tuple3 a b c
    deriving (Eq,Ord,Show)

ghci> sort [Tuple3 1 2 4, Tuple3 1 2 3, Tuple3 2 1 1, Tuple3 1 3 5]
[Tuple3 1 2 3,Tuple3 1 2 4,Tuple3 1 3 5,Tuple3 2 1 1]

ghci> sort [(1,2,4), (1,2,3), (2,1,1), (1,3,5)]
[(1,2,3),(1,2,4),(1,3,5),(2,1,1)]

No surprises here. Just another place where we have the lexicographic
ordering by default.

HTH,

-- 
Ozgur Akgun
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110304/b57b9d26/attachment.htm>


More information about the Haskell-Cafe mailing list