
On Fri, Dec 30, 2011 at 01:28:42PM +0100, Stanisław Findeisen wrote:
On 2011-12-30 12:58, Brandon Allbery wrote:
2011/12/30 Stanisław Findeisen
mailto:stf-list@eisenbits.com> Could anyone please explain to me what is going on here?
You must, when declaring an instance of Ord, provide *either* a definition of (compare) or a definition of (<=). Both have default implementations defined, but in terms of each other; so if you don't provide either one in your instance declaration, you get an infinite loop when you try to use Ord methods (because (compare) invokes (<=), which invokes (compare) ...).
If you don't provide either one, then you get an infinite loop, but this is a runtime problem, i.e. the code will compile. Right?
Correct.
How to declare an instance of Ord?
instance Ord SomeType where compare x y = ... Declaring instances of type classes should be covered in any Haskell tutorial. -Brent