Hello,<div><br></div><div>This post is (hopefully) literate Haskell.  I recently noticed that there are two ways to specify instances in a common situation.  Suppose I have something like this:</div><div><br></div><div>&gt; {-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, NoMonomorphismRestriction, OverlappingInstances #-}</div>
<div>&gt; </div><div>&gt; data A = A</div><div>&gt; data B = B</div><div>&gt; data C = C</div><div>&gt; </div><div>&gt; newtype Repr a = Repr { unRepr :: State MyState a }</div><div>&gt; </div><div>&gt; class SomeClass a b where</div>
<div>&gt; </div><div><br></div><div>If I want to make instances of SomeClass for Repr, A and Repr, B, I have two choices:</div><div><br></div><div>&gt; instance SomeClass Repr A where</div><div>&gt; instance SomeClass Repr B where</div>
<div>&gt;</div><div><br></div><div>or I can introduce a new class and make an instance with a context,</div><div><br></div><div><div>&gt; class RClass c where</div><div>&gt; </div><div>&gt; instance RClass A where</div><div>
&gt; instance RClass B where</div><div>&gt; -- no C instance for RClass</div></div><div>&gt; </div><div>&gt; instance RClass x =&gt; SomeClass Repr x</div><div><br></div><div>is there any reason to prefer one form over the other?  Of course the first requires more instance declarations, but they&#39;re auto-generated so that doesn&#39;t bother me.</div>
<div><br></div><div>Thanks,</div><div>John L.</div>