[Haskell-cafe] What puts False before True?

Brandon Michael Moore brandon at heave.ugcs.caltech.edu
Thu May 31 16:51:20 EDT 2007

On Thu, May 31, 2007 at 10:03:05AM +0100, PR Stanley wrote:
> >> What is the basic philosophy for Bool being a member of Ord?

I hear two questions, why is Bool a member of Ord at all, and
why was it ordered with False before True.

If I'm reading the reports correctly, the Ord instance was
actually added in the Haskell 1.1 standard, by changing the
definition of Bool from 

data Bool = True | False


data Bool = True | False deriving (Eq, Ord, Ix, Enum, Text, Binary)

(Text was later broken into Read and Show)

I imagine it was added because you generally can't derive an
instance of a class for a new type unless all the types you
mention in the definition already have instances. Also, there
are Ord instances like (Ord a, Ord b) => Ord (a,b), and
it's sometimes handy to be able to use types like (String, Bool)
as keys in a Map, or keep them in a Set. Probably there are
other useful things you can do.

> >> What justifies False < True?
> >in most interpretations this equals:
> >
> >False == 0
> >True == 1
>Indeed, it's the same in C but what justifies the decision in Haskell?

It seems like we actually get that order because deriving Ord makes
constructors earlier in the definition compare greater than later
constructors, and nobody was bothered by that ordering. I can't
see how one of the orders could be more expressive or otherwise
technically better than the other, so I suppose you might as well
agree with other conventions. I think it's mathematical convention
more than the C convention Haskell is agreeing with.

But this is all just speculation - the members of the Haskell comittee could
tell us why this all actually happened, and at least a few read this list.


More information about the Haskell-Cafe mailing list