Readline read_history and write_history addition

Robert Dockins robdockins at fastmail.fm
Mon Jan 21 14:09:59 EST 2008


On Monday 21 January 2008 01:27:35 pm Judah Jacobson wrote:
> > On Jan 19, 2008 11:09 AM, Judah Jacobson <judah.jacobson at gmail.com> wrote:
> > > On Jan 18, 2008 11:10 PM, Alexander Dunlap <alexander.dunlap at gmail.com> 
wrote:
> > > > Hello all,
> > > >
> > > > I'd like to propose the addition of read_history and write_history
> > > > bindings to the readline library. I believe I've followed the
> > > > instructions on the Haskell wiki appropriately and I've set up a
> > > > ticket (with a patch) at
> > > > http://hackage.haskell.org/trac/ghc/ticket/2053.
> > > >
> > > > Essentially, the patch adds simple bindings so that Haskell programs
> > > > can use Readline's read_history and write_history functions. This
> > > > will be useful for the implementation of
> > > > http://hackage.haskell.org/trac/ghc/ticket/2050 (add persistent
> > > > history to GHCi) and potentially other applications.
> > > >
> > > > Thanks for your time and consideration.
> > > >
> > > > Alex
> > >
> > > That patch looks good to me.  While we're at it, can we also add the
> > > following related functions, which are used to control the maximum
> > > size of the history file?  (They're also provided by editline.)
> > >
> > > void             clear_history(void);
> > > void             stifle_history(int);
> > > int              unstifle_history(void);
> > > int              history_is_stifled(void);
>
> One more suggestion, from Robert Dockins (author of the Shellac and
>
> Shellac-readline packages):
> > The only concern I have is that this patch doesn't seem to
> > be handling errors properly.  read_history and write_history should
> > return errno, but this binding has them returning ().  These functions do
> > file operations and therefore can fail; we want (be able) to know when
> > that happens.
>
> I think we should just throw an error if those functions return a
> nonzero value; for example, we already do that in the functions
> readInitFile and parseAndBind.

Ha, I was just now composing an email to this effect.  In addition, it would 
be nice for me if you could include:

history_max_entries :: IO Int

You can get this from readline by peeking this variable:

foreign import ccall "readline/history.h &history_max_entries" 
history_max_entries :: Ptr CInt


Then I could completely remove direct FFI bindings from my packages.

> Thanks,
> -Judah



More information about the Libraries mailing list