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. Get started.