<div dir="ltr">I see the problem now Sean. So in your example, is this correct:<div><br></div><div>"To use the machinery of 'Show', I have to add and instance Show T. But that would be an orphan instance. So there is no way for T to use show machinery without adding an orphan instance (aside from modifying a module not under your control)?"</div><div><br></div><div>Even newtype doesn't seem to help in your example. Show has all this machinery, but it seems completely unusable without adding an orphan instance or re-writing other people's modules. Is there no other way? This situation seems incredibly against re-usability, which I thought was Haskell's strength. Am I missing something?<br><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Aug 24, 2015 at 9:07 PM, Sean Leather <span dir="ltr"><<a href="mailto:sean.leather@gmail.com" target="_blank">sean.leather@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><span class=""><div class="gmail_quote">On Mon, Aug 24, 2015 at 12:48 PM, Clinton Mead wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="overflow:hidden">After implementing the steps in (c), T is an instance of both C and C1, and both those instances define foo the same way. The only way I see a problem if is a module imports both C1 and C unqualified (they'll clash) <span></span>but I see no reason to do that.</div></blockquote></div><br></span>It's hard to respond with vague details. It may be in your case that what you say works. But this is not true in the general case. Consider the following simple example.</div><div class="gmail_extra"><br></div><div class="gmail_extra">-- | A module out of your control<br></div><div class="gmail_extra">module A where</div><div class="gmail_extra">data T = T</div><div class="gmail_extra"><br></div><div class="gmail_extra">-- | A module out of your control</div><div class="gmail_extra">module B where</div><div class="gmail_extra">class Show a where</div><div class="gmail_extra">  show :: a -> String</div><div class="gmail_extra">print :: Show a => a -> IO ()</div><div class="gmail_extra"><br></div><div class="gmail_extra">-- | A module under your control</div><div class="gmail_extra">module C where</div><div class="gmail_extra">import A</div><div class="gmail_extra">import B</div><div class="gmail_extra">class Show' a where</div><div class="gmail_extra">  show' :: a -> String</div><div class="gmail_extra">instance Show' T where</div><div class="gmail_extra">  show' T = "T"</div><div class="gmail_extra"><br></div><div class="gmail_extra">Now, you can use "show' T" anywhere you could use "show T" because the result of both functions is the same (monomorphic) type.</div><div class="gmail_extra"><br></div><div class="gmail_extra">But you can't use "print T" from module B because you do not have an instance for Show of T. You could define a function "print' :: Show' a => a -> IO ()", but you are not using the functions that rely on Show (a.k.a. the "machinery" mentioned by Miguel). Thus, you lose out on the common functionality that presumably exists for Show.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Regards,</div><div class="gmail_extra">Sean</div></div>
</blockquote></div><br></div>