[Haskell-cafe] Ambiguous type signature in class declaration
benjamin.franksen at bessy.de
Wed Apr 27 18:17:24 EDT 2005
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).
More information about the Haskell-Cafe