Readline read_history and write_history addition

Yitzchak Gale gale at
Sat Feb 2 14:30:28 EST 2008

Alexander Dunlap wrote:
> For instances where an exception would be too intrusive, I don't see
> how it would be too hard to write a wrapper function

In a library that does not have direct access to the IO
monad, it would be not just hard - it would be impossible.
That is because of type restrictions in the current versions
of catch, block, and friends.

For example, if you are writing a library that exports
something like:

class MonadIO m => MyMonad m where...

you can't block or catch exceptions, so you have
to limit yourself as much as possible to operations
that are unlikely to throw IO exceptions. Otherwise,
you have to pass on responsibility to users of the
library, which makes the library much less useful.

That, in turn, would make the use of readline very awkward
and complex - or in some cases even impossible - in
programs based on monad transformers, one of the
most beautiful and powerful idioms in Haskell.
What a shame.

(The other case is the one Ian mentioned, but as he
points out, that could be considered a bug in the

On the other hand, it would never be too intrusive to write
a wrapper providing an exception if that is really required.
So that would be more general.

The question becomes: given all of the other bindings in
this readline library, is there any conceivable simple
usage of readline that would usually not raise exceptions?
If not, we should try to fix that. Otherwise, the situation is
hopeless anyway, so then it would sadly not make any
difference what we do with this particular binding.


More information about the Libraries mailing list