Future of "Text.Show.Functions" module

Michael Snoyman michael at snoyman.com
Sun Oct 19 19:00:23 UTC 2014


On Sun, Oct 19, 2014 at 4:55 PM, Malcolm Wallace <malcolm.wallace at me.com>
wrote:

>
> On 19 Oct 2014, at 11:20, Herbert Valerio Riedel wrote:
>
> >  -- This module deliberately declares orphan instances:
> >  {-# OPTIONS_GHC -fno-warn-orphans #-}
> >
> >  -- | Optional instance of 'Text.Show.Show' for functions:
> >  --
> >  -- > instance Show (a -> b) where
> >  -- >    showsPrec _ _ = showString \"\<function\>\"
> >  --
> >
> -----------------------------------------------------------------------------
> > Should this module be
> > deprecated, removed, alternatively, should the `Show` instance be made a
> > non-orphan (e.g. by importing it by the `Prelude` module), or shall this
> > curiousity be just left untouched in `base` in its current form?
>
>
> Under no circumstances should this instance ever be visible from the
> Prelude.
>
> It was deliberately made an orphan because the instance is non-conformant
> to the intended semantics of the Show class.  Having a default instance of
> Show for functions would be a disaster, by causing static type error
> messages that indicate an arity problem, to become erratic runtime
> behaviours instead (without even throwing an exception).
>
>
While I'm sensitive to this position (thus my very reluctant +0.5 on
merging into Prelude), I don't see the "disaster" you're referring to. The
only case I can picture where this might happen is when you have a value
that you are *only* ever displaying, not using in any other way. But won't
it become painfully obvious very quickly that you messed up?

Can you describe concretely a scenario where the presence of this instance
in Prelude would cause a disaster?

And if the instance is really as bad as that, I think having it in base at
all is a mistake. All it takes it one library upstream from you to import
that module, and you've been infected.

Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20141019/5d529f78/attachment.html>


More information about the Libraries mailing list