darcs

Issue 387 wish: avoid use of 'show' on exceptions

Title wish: avoid use of 'show' on exceptions
Priority wishlist Status given-up
Milestone Resolved in
Superseder Nosy List darcs-devel, dmitry.kurochkin, jch, kowey, markstos, thorkilnaur, tommy
Assigned To
Topics

Created on 2007-01-12.02:03:25 by droundy, last changed 2017-07-30.23:06:49 by gh.

Messages
msg1402 (view) Author: droundy Date: 2007-01-12.02:03:16
I'm cc'ing this to the bug tracker to create a bug for the feature request
described below, which came up from an idea of Juliusz...

On Fri, Jan 12, 2007 at 01:19:36AM +0100, Josef Svenningsson wrote:
> On 1/11/07, David Roundy <droundy@darcs.net> wrote:
> >I think we'd really like to apply it not to the method, but to the instance
> >itself.  So that use of the Show instance of Control.Exception.Exception
> >would be deprecated.  This'd be more severe, since there might be classes
> >that depend on a show instance, but don't actually use it.
> >
> >Another possibility for this particular problem would be to be able to
> >rewrite the show instance.  If we could just remove the stupid "User
> >error:" text from the show instance, I don't think it'd be a bug to use it
> >anymore.
> 
> I did a little testing and it turns out that you can actually achieve
> what you want. Just write another Show instance for C.E.Exception and
> import it wherever there is a possibility that a bad show might be
> lurking. GHC will only complain about duplicate instances if you
> actually use a method from the Show class with the particular type
> which has several instances. So GHC is doing exactly what you want!

Cool! (I would have expected it to cause trouble even when we don't use
show.) I think this'd be a great little cleanup.  We could put the import
in impossible.h, which is #included almost everywhere.  :)

For the benefit of the bug tracker, the idea is that we want to avoid using
the Show instance of Control.Exception.Exception, which has the
disadvantage of sometimes displaying "User error: xxx" when we failed with
code such as error "xxx".  This isn't the user's fault, and we should never
use this show instance (except if we've already checked that the exception
is not a UserException or whatever it's called).  Adding this code to
impossible.h will probably also require fixing a few (bad) uses of show.

David
msg2878 (view) Author: markstos Date: 2008-01-30.01:22:29
Since it's been a year since this was opened and there have been new GHC
releases, I'm curious if there's been a change in the status of this. As a user,
I don't recall triggering an error any time recently which displayed "User Error: "
msg2898 (view) Author: droundy Date: 2008-01-30.14:58:24
Actually, I recently fixed one such bug, so this would still be useful.
msg2901 (view) Author: droundy Date: 2008-01-30.15:04:56
However, it seems that this may be trickier than we thought.  A quick experiment
suggests that I can't define a Show instance for Control.Exception.Exception,
since I can't import the type Control.Exception.Exception without also importing
its show instance.  :(

David
msg2904 (view) Author: droundy Date: 2008-01-30.15:06:08
The trouble, by the way, is the fact that importing a module automatically
imports all instances defined in that module, whether we want them or not.
msg8633 (view) Author: kowey Date: 2009-09-02.09:56:39
I don't really understand this bug.

On a high level, I get that calling 'show' on Control.Exception.Exception where
the error is xxx gives us a useless 'User error: xxx' message (when clearly the
user isn't at fault).

Question I'd like somebody to answer: What exactly triggers this?  Is it as
simple as explicitly calling show, as in 'show e'?  If so why not extend our
policy mechanism to catch this?
msg8634 (view) Author: markstos Date: 2009-09-02.13:41:27
Given that's been over a year with no follow-up comments this bug, 
I would be OK with considering it "resolved" or "needs confirmation"
until someone else runs into it. I haven't personally triggered the issue
that I recall.
History
Date User Action Args
2007-01-12 02:03:25droundycreate
2007-01-12 14:20:24droundysetnosy: droundy, tommy, beschmi, kowey, darcs-devel, josef.svenningsson
title: GHC and flagging use of a given constant -> avoid use of show on exceptions
2007-01-12 14:21:15droundysetnosy: + jch, - darcs-devel, josef.svenningsson
2008-01-30 01:22:30markstossetstatus: unread -> unknown
nosy: + markstos
messages: + msg2878
2008-01-30 14:58:25droundysetnosy: droundy, jch, tommy, beschmi, kowey, markstos
messages: + msg2898
2008-01-30 15:04:57droundysetnosy: droundy, jch, tommy, beschmi, kowey, markstos
messages: + msg2901
2008-01-30 15:06:09droundysetnosy: droundy, jch, tommy, beschmi, kowey, markstos
messages: + msg2904
2008-02-16 18:56:36markstossetpriority: feature -> wishlist
status: unknown -> deferred
nosy: droundy, jch, tommy, beschmi, kowey, markstos
title: avoid use of show on exceptions -> wish: avoid use of 'show' on exceptions
2009-08-06 17:38:13adminsetnosy: + jast, Serware, dmitry.kurochkin, darcs-devel, zooko, dagit, mornfall, simon, thorkilnaur, - droundy, jch
2009-08-06 20:35:02adminsetnosy: - beschmi
2009-08-10 22:00:47adminsetnosy: + jch, - darcs-devel, zooko, jast, dagit, Serware, mornfall
2009-08-25 17:51:50adminsetnosy: + darcs-devel, - simon
2009-08-27 13:55:39adminsetnosy: jch, tommy, kowey, markstos, darcs-devel, thorkilnaur, dmitry.kurochkin
2009-09-02 09:56:41koweysetstatus: deferred -> needs-reproduction
nosy: jch, tommy, kowey, markstos, darcs-devel, thorkilnaur, dmitry.kurochkin
messages: + msg8633
2009-09-02 13:41:29markstossetnosy: jch, tommy, kowey, markstos, darcs-devel, thorkilnaur, dmitry.kurochkin
messages: + msg8634
2017-07-30 23:06:49ghsetstatus: needs-reproduction -> given-up