Readline readHistory & writeHistory API broken

The current readHistory and writeHistory bindings are defined as: -- |Read in a history file. Returns 'False' on failure -- (for example, if the file does not exist). readHistory :: FilePath -- ^ The file to read (if null, read ~\/.history) -> IO Bool readHistory fp = do ok <- withCString fp read_history return (ok==0) foreign import ccall unsafe read_history :: Ptr CChar -> IO CInt -- |Write out a history file. Returns 'False' if there was a problem writing the file. writeHistory :: FilePath -- ^ The file to write (if null, write ~\/.history) -> IO Bool writeHistory fp = do ok <- withCString fp write_history return (ok==0) foreign import ccall unsafe write_history :: Ptr CChar -> IO CInt Note the comments "(if null, write ~/.history)"! This is supported in the original C API but in Haskell the filepath cannot be null. In the best case it can be empty string. Either the type signatures have to be changed to accept (Maybe FilePath) or the comments have to be changed because the Haskell binding currently doesn't support this functionality. Comments? I hope that this will not start another endless discussion. Regards, Krasimir

On Sun, Jun 08, 2008 at 05:30:34PM +0200, Krasimir Angelov wrote:
Note the comments "(if null, write ~/.history)"! This is supported in the original C API but in Haskell the filepath cannot be null. In the best case it can be empty string. Either the type signatures have to be changed to accept (Maybe FilePath) or the comments have to be changed because the Haskell binding currently doesn't support this functionality.
If writing to ~/.history is useful then Maybe FilePath makes sense to me, as ~/.history is a bit fiddly to work out yourself. However, it doesn't sound that useful to me, as then all applications would trample over each other. If you want to propose that it uses Maybe FilePath then you'll need to follow http://www.haskell.org/haskellwiki/Library_submissions; otherwise I'll just fix the comments. Thanks Ian

Just fixing the comments is also fine for me. I personally use another
file name.
On 6/11/08, Ian Lynagh
On Sun, Jun 08, 2008 at 05:30:34PM +0200, Krasimir Angelov wrote:
Note the comments "(if null, write ~/.history)"! This is supported in the original C API but in Haskell the filepath cannot be null. In the best case it can be empty string. Either the type signatures have to be changed to accept (Maybe FilePath) or the comments have to be changed because the Haskell binding currently doesn't support this functionality.
If writing to ~/.history is useful then Maybe FilePath makes sense to me, as ~/.history is a bit fiddly to work out yourself.
However, it doesn't sound that useful to me, as then all applications would trample over each other.
If you want to propose that it uses Maybe FilePath then you'll need to follow http://www.haskell.org/haskellwiki/Library_submissions; otherwise I'll just fix the comments.
Thanks Ian
participants (2)
-
Ian Lynagh
-
Krasimir Angelov