<p dir="ltr">From time to time, a library lacks an instance for something that I want. For example, I may need to convert</p>
<p dir="ltr">data Foo = Bar (Vector Baz)</p>
<p dir="ltr">to FishFood, but (to avoid unreasonable dependencies) Vector doesn't have a ToFishFood instance, so I can't just write</p>
<p dir="ltr">instance ToFishFood Foo</p>
<p dir="ltr">and (using Generic magic) be done with it. Instead, I must write the instance completely by hand, which could be painful. I *could* write an orphan instance, but orphans are evil.</p>
<p dir="ltr">What I wish I could do:</p>
<p dir="ltr">newtype Vec a = Vec (Vector a)</p>
<p dir="ltr">instance ToFishFood a => (newtype Vec) a where<br>
-- if needed<br>
toFishFood (v :: Vector a) = ...</p>
<p dir="ltr">That is, I want to write a super-secret orphan instance for Vector and transfer it to Vec via GND precisely when it is legal to do so. The secret instance could itself be derived (if the constructors are visible) or could make use of default member definitions.</p>