instance visibility

David Roundy droundy at darcs.net
Wed Sep 24 15:09:29 EDT 2008


On Wed, Sep 24, 2008 at 07:48:06PM +0100, Simon Marlow wrote:
> David Roundy wrote:
>
>> In the interest of providing a concrete example, see the darcs bug:
>>
>> http://bugs.darcs.net/issue387
>
> Nice motivation for wanting to *not* import an instance.
>
> The first thing that occurs to me is to avoid using UserError - is that
> feasible?

It's feasible, but extremely ugly, and it seems almost impossible to
audit the code for this, as we'd have to look at every instance of
fail to see if it might happen to be used in the IO monad.  And, of
course, we'd have to write our own version of error.  Either of these
sounds very tricky.  fail is a great function (albeit much maligned),
and I'd hate to have to replace it throughout the code.

Now, if we could avoid importing the Monad instance of IO from the
Prelude, then we could write our own instance that would have a fail
such as

fail = throw . AssertionFailed

David


More information about the Libraries mailing list