[Haskell-cafe] Deduce problem.

MigMit miguelimo38 at yandex.ru
Thu Nov 17 06:01:06 CET 2011


Of course, b can be H. The important question is: why can't it be something else? ClassC signature implies that b can be anything (of class ClassB) — not just H.

Another error is that you declare from as returning a list, but you try to implement it as returning a single value.

On 17 Nov 2011, at 08:54, Magicloud Magiclouds wrote:

> I think this is where I did not understand from the very beginning.
> If the the declaration was correct, then why cannot b be H?
> Referring to Data.List.genericLength, I was confused.
> 
> On Thu, Nov 17, 2011 at 12:34 PM, MigMit <miguelimo38 at yandex.ru> wrote:
>> You've declared "from" as forall b. Test -> [b], but you're trying to implement it as Test -> H.
>> 
>> On 17 Nov 2011, at 07:48, Magicloud Magiclouds wrote:
>> 
>>> Hi,
>>>  Consider I have declarations like this:
>>> class (ClassA a) => ClassC a where
>>>  from :: (ClassB b) => a -> [b]
>>>  to :: (ClassB c) => a -> [c]
>>> 
>>> data H = ...
>>> 
>>> instance ClassB H where
>>>  ...
>>> 
>>> data Test = Test { m :: H }
>>> instance ClassA Test where
>>>  ...
>>> instance ClassC Test where
>>>  from = m
>>>  to = m
>>> 
>>>  Well, I got "could not deduce" error here at "from = m" and "to =
>>> m". `c' is a rigid type variable bound by the type signature for to ::
>>> ClassB c => Test -> [c].
>>>  Referring to some similar questions on internet, I should remove the
>>> (ClassB c) thing. Is this the only solution?
>>> --
>>> 竹密岂妨流水过
>>> 山高哪阻野云飞
>>> 
>>> _______________________________________________
>>> Haskell-Cafe mailing list
>>> Haskell-Cafe at haskell.org
>>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>> 
>> 
> 
> 
> 
> -- 
> 竹密岂妨流水过
> 山高哪阻野云飞




More information about the Haskell-Cafe mailing list