Future of "Text.Show.Functions" module

Reid Barton rwbarton at gmail.com
Sun Oct 19 13:50:57 UTC 2014


On Sun, Oct 19, 2014 at 9:18 AM, Herbert Valerio Riedel <hvr at gnu.org> wrote:

> On 2014-10-19 at 12:20:23 +0200, Herbert Valerio Riedel wrote:
>
> [...]
>
> >   instance Show (a -> b) where
> >           showsPrec _ _ = showString "<function>"
>
> PS: An effect of having this instance made default in Prelude is that
>     GHCi would show a somewhat different result in some cases (not sure
>     though if this a good or bad thing):
>
>
>       GHCi, version 7.8.3: http://www.haskell.org/ghc/  :? for help
>       Loading package ghc-prim ... linking ... done.
>       Loading package integer-gmp ... linking ... done.
>       Loading package base ... linking ... done.
>       λ:2> id
>
>       <interactive>:2:1:
>           No instance for (Show (a0 -> a0)) arising from a use of ‘print’
>           In a stmt of an interactive GHCi command: print it
>       λ:3> import Text.Show.Functions
>       λ:4> id
>       <function>
>       it :: a -> a


You seem to have ":set +t" on (show types), which isn't the default unless
it changed in HEAD very recently.

I'm -1 for reasons including

* Worse usability in ghci by default. If I see "No instance for (Show
(IOMode -> IO Handle))", I can figure out that I omitted an argument of
type IOMode, but if I see "<function>" I only know that I omitted some
argument, and I have to redo the command with :t to learn more.

* Precludes other instances Show (a -> b), some of which already exist in
the wild, e.g. lambdabot's that uses Typeable to produce a string like
"<Char -> Int>" (but breaks down in the presence of polymorphism), or the
'countable' package's (Show a,Finite a,Show b) => Show (a -> b).

* I don't see what we gain by forcing this instance on everybody rather
than letting people opt in with "import Text.Show.Functions". When was the
last time you encountered an error because two of your imports exported
different Show (a -> b) instances? Orphan instances are bad in general, but
for debugging hacks I think they're fine.

I'm neutral on whether to remove Text.Show.Functions or leave it as is.
FWIW, I was unaware of its existence before your email.

Regards,
Reid Barton
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20141019/1d8d08fb/attachment-0001.html>


More information about the Libraries mailing list