
27 Apr
2005
27 Apr
'05
6:17 p.m.
On Wednesday 27 April 2005 22:12, Benjamin Franksen wrote:
Another trick is to split the class:
class Countable a where count :: a -> Maybe Integer -- Nothing means infinity
class Countable a => CRank a b where rank :: ... ...
This solution has similar disadvantages as the fundep variant, that is, there can be only one instance for 'Countable Prime' and not two different ones (like an infinite count for Integer Primes and a finite one for Ints). In fact, this seems to be a standard way to achieve the effect of fundeps without actually using them (although I have read somewhere that it doesn't work in all cases). Ben