[Haskell-cafe] Problems instancing a class
Benjamin Franksen
benjamin.franksen at bessy.de
Fri Feb 17 16:20:42 EST 2006
On Friday 17 February 2006 21:03, Juan Carlos Arevalo Baeza wrote:
> What really got me is that if I don't use a type synonym:
>
> instance MyClass (HT.HashTable String String) where
> htLookup h var =
> do result <- HT.lookup h var
> case result of
> Nothing -> return ""
> Just s -> return s
>
> it still complains:
>
> Illegal instance declaration for `MyClass (HashTable String String)'
> (The instance type must be of form (T a b c)
> where T is not a synonym, and a,b,c are distinct type variables)
> In the instance declaration for `MyClass (HashTable String String)'
>
> even though the documentation in GHC states that HashTable is
> declared as "data".
(Guessing) Maybe because 'String' is not a type variable?
> How exactly is type undecidable if this is allowed? I found here:
>
> http://hackage.haskell.org/trac/haskell-prime/wiki/FlexibleInstances
>
> an example of a non-terminating instance:
>
> instance C b b => C (Maybe a) b
>
> I don't see how/where/when this would be non-terminating. I
> mean... if you now define an instance "C Int Int", then you actually
> also have "C (Maybe Int) Int", C (Maybe (Maybe Int)) Int" and so on,
> I can see that. But how exactly is that a problem? Can you show me a
> use of C that cannot work with that instance?
What is (or better: might be) non-terminating is the process (algorithm)
of /type inference/. This:
http://www.haskell.org//pipermail/haskell-prime/2006-February/000609.html
message contains a detailed explanation.
Ben
More information about the Haskell-Cafe
mailing list