Re: [Haskell-cafe] FW: Why does this Ord-class instance crash?

2010-05-21 Thread Daniel Fischer
On Friday 21 May 2010 19:06:51, R J wrote: > Why does the following, trivial code snippet below hang GHCi when I > type"Scalene > Failure", and what's the fix? For an Ord instance, you need to define at least one of compare and (<=) or the other functions from the class won't work. All methods h

Re: [Haskell-cafe] FW: Why does this Ord-class instance crash?

2010-05-21 Thread Miguel Mitrofanov
From Prelude.hs: class (Eq a) => Ord a where compare :: a -> a -> Ordering (<), (<=), (>), (>=) :: a -> a -> Bool max, min :: a -> a -> a compare x y = if x == y then EQ -- NB: must be '<=' not '<' to validate the --

Re: [Haskell-cafe] FW: Why does this Ord-class instance crash?

2010-05-21 Thread David Menendez
2010/5/21 R J : > Why does the following, trivial  code snippet below hang GHCi when I type > "Scalene > Failure", and what's the fix? An instance of Ord must declare compare or (<=). You only defined (<), so (>) is using the default definition. Here are the defaults: compare x y = if x == y

[Haskell-cafe] FW: Why does this Ord-class instance crash?

2010-05-21 Thread R J
Why does the following, trivial code snippet below hang GHCi when I type"Scalene > Failure", and what's the fix? data Triangle = Failure | Equilateral | Isosceles | Scalene