[Haskell-beginners] "Delegating" class instance definition

Nadir Sampaoli nadirsampaoli at gmail.com
Sat Oct 11 23:03:09 UTC 2014


> Looking closer I realised that when I copied & pasted the definition for
(<) to the rest of the functions and the problem actually occurred at
> ...
> max a b = max (size a) (size b)
> min a b  = min (size a) (size b)
>> which has return type of Double where it should be Cycle.

To define an Ord instance you only need to implement compare because the
other functions are derivable in terms of it.
If you wany to explicitly implement max, a correct implementation could be:

max a b = if size a < size b then b else a
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20141012/6ba7d755/attachment.html>


More information about the Beginners mailing list