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

Carter Schonwald carter.schonwald at gmail.com
Sat Aug 28 15:22:07 EDT 2010


 i believe that a valid idiom is to define a class C that has no  functions,
but requires  any instance   to also be of type classes A and B, so that you
can write: C a => blah
rather than (A a,B a)=> blah, though I don't know how often such is used in
practice

the same idea should apply more generally to multiparam type classes

On Sat, Aug 28, 2010 at 5:44 AM, João Paulo <jpaulo at di.uminho.pt> wrote:

>
> 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
>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100828/2be1add7/attachment.html


More information about the Haskell-Cafe mailing list