[Haskell-cafe] (automatic) type classes context inference

João Paulo jpaulo at di.uminho.pt
Sat Aug 28 05:44:02 EDT 2010


Hello everyone,

I am developing a toolset in which I have several (multiparameter)  
type classes;

It is often the case that I can only define a data-type X as an  
instance of one such class (say A), if X is an instance of another  
class (say B);

The thing is that, while it is hard for me, because of all the type  
parameters that I have to deal with, to add

   'X is an instance of B'

to the context cxt_A in

   'instance cxt_A => A X'

ghc is always able to correctly infer all type parameters; In fact, I  
always get:

   'Could not deduce (B X t1 ... tn)
       from the context cxt_A arising from ...
    Probable fix: add (B X t1 ... tn) to the context cxt_A ...'

In my case, this is the fix that I always need: most of the times, I  
am just copy-pasting (B X t1 ... tn) to cxt_A!

Is there a way, say a compilation option, to avoid this?

can anyone please help me here? :)

thank you very much

--
João Paulo Fernandes
Universidade do Minho
www.di.uminho.pt/~jpaulo





More information about the Haskell-Cafe mailing list