[Haskell-cafe] Re: Some clarity please!

Ketil Malde ketil at malde.org
Thu Mar 13 07:05:18 EDT 2008

Aaron Denney <wnoise at ofb.net> writes:

> Well, the way the report specifies that max's default definition
> is.  I'd actually favor making that not an instance function at
> all, and instead have max and min be external functions.

If you permit a naïve question:

Prelude> :i Ord
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

..while all functions could be easily derived from 'compare'.  Or from
the Eq instance's (==) and (<), say.

What is the reason for this?  Efficiency?  (Which couldn't be handled
equally well by RULES?)  Otherwise, it looks like an invitation for
writing inconsistent instances.

If I haven't seen further, it is by standing in the footprints of giants

More information about the Haskell-Cafe mailing list