While you may define this *Ord* instance by defining the *compare* method, you should probably not do this since *Ord* is supposed to follow some rules, in particular transitivity "*a < b and b < c means a < c*" is assumed but false in your case. Those rules are important for many functions to work correctly (sort, minimum, maximum and so on...). You may simply define another function like *winAgainst* : *Rock `winAgainst` Scissors = True* *Scissors `winAgainst` Paper = True* *Paper `winAgainst` Rock = True_ `winAgainst` _ = False* or maybe a *battle* function that returns a *Win | Loss | Tie*... (NB : All functions can be used as infix by surrounding their name with ` (antiquotes)) Le jeu. 30 juil. 2015 à 15:34, Nikita Danilenko <nda@informatik.uni-kiel.de> a écrit :
Hi Derek,
you can find the desired functions and type classes using Hoogle [1]. Your attempt at an Ord instance is basically the right idea, but you need to define the function "compare" only [2]. From your syntax it looks like you are trying to define a function called "ord" that additionally uses "compare" (in a way, it cannot be used). Removing "ord" in all three cases fixes your problem, although the resulting function "compare" is not total.
The documentation of the type classes usually contains a description of what functions you need to define. The fact that the "Show" type class instance can be obtained using a function called "show" is a coincidence.
Best regards,
Nikita
[1] https://www.haskell.org/hoogle/
[2] http://hackage.haskell.org/package/base-4.8.1.0/docs/Prelude.html#t:Ord