System.Posix.IO.ByteString fdRead and fdWrite.

In unix-2.7.0.0, fdRead and fdWrite in System.Posix.IO.ByteString use String instead of ByteString. This is wrong, isn't it? The point of the .ByteString modules is to do IO in ByteString. -- Ashley

On Wed, Nov 20, 2013 at 6:03 PM, Ashley Yakeley
In unix-2.7.0.0, fdRead and fdWrite in System.Posix.IO.ByteString use String instead of ByteString. This is wrong, isn't it? The point of the .ByteString modules is to do IO in ByteString.
No. ByteString provides its own routines for that. The point of System.Posix.IO.ByteString is to provide a ByteString (which is to say, a correct POSIX) interface to *filesystem paths*. Using String for these is entirely incorrect, because POSIX pathnames are literally byte strings --- there is no encoding, just raw bytes with only '/' and '\NUL' being special. There are *lots* of programs that behave weirdly or crash because they assume the filesystem uses normalized UTF8, but absolutely nothing forces pathnames to be UTF8 much less normalized UTF8. (Gtk+ file dialogs tend to crash with non-UTF8-encoded filenames. They do even weirder things when filenames are UTF8 but not normalized. OS X native file dialogs have similar problems.) -- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net

On 2013-11-21 at 00:03:46 +0100, Ashley Yakeley wrote:
In unix-2.7.0.0, fdRead and fdWrite in System.Posix.IO.ByteString use String instead of ByteString. This is wrong, isn't it? The point of the .ByteString modules is to do IO in ByteString.
Fwiw, here's the commit introducing the ByteString API and stating its intention: http://git.haskell.org/packages/unix.git/commitdiff/34c7bf896f19b182cf6fa104... However, I'm not totally sure from that, whether the type-sigs fdRead :: Fd -> ByteCount -- ^How many bytes to read -> IO (String, ByteCount) -- ^ The bytes read, how many bytes were read. fdWrite :: Fd -> String -> IO ByteCount were really intended to be that way. Simon, maybe you can provide some insight here? Cheers, hvr

On 21/11/13 08:18, Herbert Valerio Riedel wrote:
On 2013-11-21 at 00:03:46 +0100, Ashley Yakeley wrote:
In unix-2.7.0.0, fdRead and fdWrite in System.Posix.IO.ByteString use String instead of ByteString. This is wrong, isn't it? The point of the .ByteString modules is to do IO in ByteString.
Fwiw, here's the commit introducing the ByteString API and stating its intention:
http://git.haskell.org/packages/unix.git/commitdiff/34c7bf896f19b182cf6fa104...
However, I'm not totally sure from that, whether the type-sigs
fdRead :: Fd -> ByteCount -- ^How many bytes to read -> IO (String, ByteCount) -- ^ The bytes read, how many bytes were read.
fdWrite :: Fd -> String -> IO ByteCount
were really intended to be that way.
Simon, maybe you can provide some insight here?
Brandon's reply is correct, the ByteString variant of the POSIX API is intended to change the representation of file paths only. These two functions are totally useless and we need better versions anyway. Cheers, Simon

On 2013-11-21 02:55, Simon Marlow wrote:
However, I'm not totally sure from that, whether the type-sigs
fdRead :: Fd -> ByteCount -- ^How many bytes to read -> IO (String, ByteCount) -- ^ The bytes read, how many bytes were read.
fdWrite :: Fd -> String -> IO ByteCount
were really intended to be that way.
Simon, maybe you can provide some insight here?
Brandon's reply is correct, the ByteString variant of the POSIX API is intended to change the representation of file paths only.
These two functions are totally useless and we need better versions anyway.
Regarding the path type issue, I wonder if it wouldn't be easier to settle on something like newtype PosixFilePath = PosixFilePath ByteString instance IsString PosixFilePath where ... -- Ashley

On 11/20/13 6:03 PM, Ashley Yakeley wrote:
In unix-2.7.0.0, fdRead and fdWrite in System.Posix.IO.ByteString use String instead of ByteString. This is wrong, isn't it? The point of the .ByteString modules is to do IO in ByteString.
The functions you're looking for are in unix-bytestring[1]. They also have precedent on the System.Posix.IO.ByteString module name, but there was a bit of a mixup back when the ByteString-based filename stuff was introduced in unix. The unix-bytestring package was always intended to be rolled into unix. When I proposed incorporating it back in the day, the original version mirrored the System.Posix.IO API and the proposal was voted down because noone liked the System.Posix.IO API! I've since redone the API to better match the POSIX standards, and have gotten positive feedback on it. So perhaps it's time to revive the proposal for inclusion. [1] http://hackage.haskell.org/package/unix-bytestring -- Live well, ~wren
participants (5)
-
Ashley Yakeley
-
Brandon Allbery
-
Herbert Valerio Riedel
-
Simon Marlow
-
wren@freegeek.org