<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Oct 19, 2014 at 1:20 PM, Herbert Valerio Riedel <span dir="ltr"><<a href="mailto:hvr@gnu.org" target="_blank">hvr@gnu.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello *,<br>
<br>
I noticed the following module (trimmed for brevitiy) hiding in `base`:<br>
<br>
<br>
  -- This module deliberately declares orphan instances:<br>
  {-# OPTIONS_GHC -fno-warn-orphans #-}<br>
<br>
  -- | Optional instance of 'Text.Show.Show' for functions:<br>
  --<br>
  -- > instance Show (a -> b) where<br>
  -- >    showsPrec _ _ = showString \"\<function\>\"<br>
  --<br>
  -----------------------------------------------------------------------------<br>
<br>
  module Text.Show.Functions () where<br>
<br>
  instance Show (a -> b) where<br>
          showsPrec _ _ = showString "<function>"<br>
<br>
<br>
However, I consider this a questionable module to be in `base` due to<br>
its deliberate use of orphan instances.  Should this module be<br>
deprecated, removed, alternatively, should the `Show` instance be made a<br>
non-orphan (e.g. by importing it by the `Prelude` module), or shall this<br>
curiousity be just left untouched in `base` in its current form?<br>
<br>
Cheers,<br>
  hvr<br>
<span class=""><font color="#888888"><br>
--<br>
You received this message because you are subscribed to the Google Groups "haskell-core-libraries" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="mailto:haskell-core-libraries%2Bunsubscribe@googlegroups.com">haskell-core-libraries+unsubscribe@googlegroups.com</a>.<br>
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank">https://groups.google.com/d/optout</a>.<br>
</font></span></blockquote></div><br></div><div class="gmail_extra">I think this really brings up the question of what `Show` should be used for. If the goal is to be simple serialization with `Read` as the inverse[1], then this is clearly a nonsense instance and shouldn't be included. If, on the other hand, we consider `Show` to be simple debug output, this makes perfect sense. Similarly, rendering `IO a` as "<IO action>" or something like that makes sense too.<br><br>An example where this came up recently was adding a Show instance to the Request type in WAI[2]. The goal there is explicitly debugging, and displaying some uninteresting string for any IO actions is very useful. Having such an instance built into base would have been convenient for auto-deriving of this Show instance.<br><br></div><div class="gmail_extra">Overall, the problem is that we've overloaded Show in (at least) three different ways:<br><br></div><div class="gmail_extra">* Textual serialization<br></div><div class="gmail_extra">* Debugging<br></div><div class="gmail_extra">* User-friendly display of data<br><br></div><div class="gmail_extra">I think I give a +0.5 to re-exporting this instance from Prelude/making it non-orphan, since:<br><br></div><div class="gmail_extra">1. I agree that orphans in base are a bad idea.<br></div><div class="gmail_extra">2. Removing the instance will possibly cause breakage for someone.<br></div><div class="gmail_extra">3. I *do* personally lean towards using Show instances for debugging purposes, and in that context, the Show instance is a good one.<br><br></div><div class="gmail_extra">Michael<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">[1] I believe the correct term is actually a retraction.<br>[2] <a href="https://github.com/yesodweb/wai/issues/290">https://github.com/yesodweb/wai/issues/290</a><br></div></div>