<div>Hello</div>
<div> </div>
<div>Consider the following data, class and instance:</div>
<div><br><font face="courier new,monospace">class PP m where    <br>    create :: a -> m a</font></div>
<div><font face="courier new,monospace"></font> </div>
<div><font face="courier new,monospace">data A a = A a </font></div>
<div><font face="courier new,monospace"></font> </div>
<div><font face="courier new,monospace">instance PP A where <br>    create a = A a</font></div>
<div> </div>
<div>And then:</div>
<div> </div>
<div><font face="courier new,monospace">class CB a where<br>    fb :: a -> Int</font></div>
<div><font face="courier new,monospace"></font> </div>
<div><font face="courier new,monospace">data B m a = B (m a) </font></div>
<div> </div>
<div><font face="arial,helvetica,sans-serif">If I try to define an instance of PP for B with the following implementation:</font></div>
<div> </div>
<div><font face="courier new,monospace">instance (PP m) => PP (B m) where<br>    create a =  let _ = fb a <br>                in B (create a)</font></div>
<div> </div>
<div>GHC issues the (expected) error: Could not deduce (CB a) arising from a use of 'fb' from the context (PP m).</div>
<div> </div>
<div>So the workaround I am using is to define a new class PP' where the type a is made more explicit. That allows the constraint (CB a) to be stated in an instance declaration.</div>
<div> </div>
<div><font face="courier new,monospace">class PP' m a where<br>    create' :: a -> m a</font></div>
<div><font face="courier new,monospace">    <br>instance (PP m) => PP' m a where<br>    create' = create    </font></div>
<div><br><font face="courier new,monospace">instance (PP m, CB a) => PP' (B m) a where<br>    create' a = let _ = fb a <br>                in B (create a)</font></div>
<div> </div>
<div> So, my question is: is there a way to achieve the same results without having to create the new class PP'?</div>
<div> </div>
<div>Thank you for your help</div>
<div> </div>
<div>J-C</div>
<div> </div>