System.Posix.IO.ByteString types?

wren ng thornton wren at freegeek.org
Tue Jul 10 09:00:23 CEST 2012


On 7/5/12 4:57 AM, 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.

It is indeed a small consideration, IMO. In order to use ByteStrings as 
the medium of the data being exchanged, you want to use the 
unix-bytestring library[1]. Unfortunately that may be taxing on newer 
GHCs since the new version of unix stole the namespaces from 
unix-bytestring.

I had tried to get unix-bytestring incorporated into unix previously 
(before unix's .ByteString modules existed), but made the unfortunate 
decision to emulate the String-based API--- and noone liked the old API 
to begin with, so the proposal was rejected. I've since modified the API 
to what I think is a nice design. It closely mirrors the official POSIX 
and XPG standards, and has been battle-tested by myself and other folks 
who were eschewing the unix package and doing their own ByteString-based 
operations. I'd love for unix-bytestring to be folded into unix itself, 
but have no time to make another proposal. If you'd like to do so on my 
behalf, feel free.


[1] http://hackage.haskell.org/package/unix-bytestring

-- 
Live well,
~wren



More information about the Libraries mailing list