wait what?

ghci> succ LT
EQ

ghci> succ EQ
GT

I'll need to sleep on why this is the case.

#haskell

@rzeta0 does this help?

[minBound .. maxBound] :: [Ordering]
[LT,EQ,GT]

@jonocarroll

I'm just trying to work out why it is semantically the successor rather than "by definition".

That is, how is it useful?

@rzeta0 @jonocarroll I think it's mainly for use with collections.

Take a list of numbers, pick a number, annotate each item with the comparison to that number, sort the annotated list - the items would be in that lt/eq/gt order wrt. to pivot.

The same as subtracting the pivot, the numbers will be negative, then zeroes, then positive.

@dpwiz @rzeta0 I think the question is about the ordering of the enum itself, not the application to a collection. There needs to be some order of the values, and perhaps it's arbitrary, but LT, EQ, GT seems the most natural.

Similarly, and perhaps more enlightening:

ghci> succ False
True
ghci> pred True
False

because it's defined as

data Bool = False | True

Follow

@jonocarroll @rzeta0 Collections are just example of doing things of least surprise. There is a web of concepts that are expected to behave similarly. If there are multiple ways to do the comparison, they ought to have same results since the underlying property is the same across all the implementations.

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.