Why does this Ord-class instance crash?

I'm trying to declare Triangle as an instance of the Ord class without using "deriving (Ord)", so I can better understand the manual instantiation. As I understand it, all I need merely to define "<". Yet, when I do so using the code snippet below, this code hangs when I type "Scalene > Failure" in GHCi. Why is that, and what's the fix? Thanks. data Triangle = Failure | Equilateral | Isosceles | Scalene deriving (Eq, Show) instance Ord Triangle where Failure < Failure = False Failure < _ = True Equilateral < Failure = False Equilateral < Equilateral = False Equilateral < _ = True Isosceles < Scalene = True Isosceles < _ = False Scalene < _ = False _________________________________________________________________ The New Busy is not the old busy. Search, chat and e-mail from your inbox. http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:W...

On May 21, 2010, at 08:13 , R J wrote:
I'm trying to declare Triangle as an instance of the Ord class without using "deriving (Ord)", so I can better understand the manual instantiation.
As I understand it, all I need merely to define "<". Yet, when I do so using the code Incorrect; you need to define "<=", not "<". Or define "compare". Since you defined "<" but not "<=", ">" fell back to "compare", which fell back to "<=", which fell back to "compare" again... You need to define one or both of those to break the loop.
-- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH
participants (2)
-
Brandon S. Allbery KF8NH
-
R J