System.Posix.IO.ByteString types?

Simon Marlow marlowsd at
Thu Jul 5 13:38:55 CEST 2012

On 05/07/2012 09:57, Ben Gamari wrote:
> Recently, I spent a fair amount of time tracking down an encoding issue[1]
> in the `serialport` package. As is often the case, `serialport` used
> Strings, which blew up quite nicely when working with a binary
> protocol. Delving into the code it eventually became fairly obvious that
> the problem was due to encoding and could be fixed by completely moving
> to ByteStrings.
> Unfortunately, while the unix package contains a
> System.Posix.IO.ByteString module, all of the functions within still
> appear to work with Strings[2]. While it appears that paths are handled
> a bit differently in the ByteString variant, but it seems like this is a
> fairly small consideration compared to the data itself.
> Have I stumbled across a bug? Is there anyway short of the non-Haskell
> Platform unix-bytestring package to get ByteStrings out of fds? If not,
> it seems this is a large hole in the interfaces exposed by unix. Is
> there any plan to remedy this?

The .ByteString variants of the modules in System.Posix were added 
primarily to address the problem that FilePath was represented as String 
in the existing System.Posix APIs, but POSIX file paths are really 
sequences of bytes.

Making ByteString versions of fdRead and fdWrite is a separate issue; 
but an important one undoubtedly.  If there's general agreement on what 
the API should be, and if someone writes a patch, I'd be happy to apply it.


More information about the Libraries mailing list