Unix/Posix-specific functions for ByteStrings. http://code.haskell.org/~wren/

Version on this page:
LTS Haskell 8.3:
Stackage Nightly 2017-02-26:
Latest on Hackage:
BSD3 licensed by wren gayle romano
Maintained by wren@community.haskell.org

Module documentation for


In general, this is a simple package and should be easy to install.
You must have hsc2hs installed in order to compile the package (but
then you probably already do). With the cabal-install program you
can just do:

$> cabal install unix-bytestring

Or if you don't have cabal-install, then you can use the Cabal library:

$> runhaskell Setup.hs configure
$> runhaskell Setup.hs build
$> runhaskell Setup.hs test
$> runhaskell Setup.hs haddock --hyperlink-source
$> runhaskell Setup.hs copy
$> runhaskell Setup.hs register

The test step is optional and currently does nothing. The Haddock
step is also optional.

FFI Problems

The unix-bytestring package uses standard POSIX header files
<sys/types.h>, <sys/uio.h>, and <unistd.h>. If Cabal has difficulty
finding these files or reports another error, be sure your include
path variables are correct. If the problem persists, contact the

Building for GHC (6.8 and above)

Nothing special to mention.

Building for Hugs (September 2006)

I haven't actually compiled this for Hugs because I don't have a
new enough version of Cabal for it, but I don't forsee any difficulties.
If you do compile this for Hugs, let the maintainer know how it

When compiling for Hugs, see the following bugs for Cabal's interaction
with ffihugs. These bugs do not currently affect this package, but
this notice is here in case they affect future versions. For more
details and a minimal regression suite, see:


(1) <http://hackage.haskell.org/trac/hackage/ticket/526>
Options in hugs-options aren't passed through to ffihugs, most
importantly -98 and +o are the ones we'd like to pass. For enabling
the +o flag Hugs-Sept06 does not honor:
pragma {-# LANGUAGE OverlappingInstances #-}
pragma {-# OPTIONS_HUGS +o #-}
cabal extensions: OverlappingInstances
And the -98 flag has similar issues. Therefore this is a real

Immediate solution: The options set in hugs-options should be passed
to ffihugs as well. As of Cabal 1.6 they are not passed (verified
by Duncan Coutts). The two programs accept all the same options,
so this is valid.

Ideal solution: Based on the extensions field, Cabal should
automatically determine whether -98 and +o need to be enabled (for
both hugs and ffihugs).

(2) <http://hackage.haskell.org/trac/hackage/ticket/527>
If CPP is being used in conjunction with FFI, then cpp/cpphs is not
called before ffihugs is called. Thus, users must pass an -F flag
to ffihugs in order to declare a code filter (and must pass all
cpp-options to -F manually). For example:

--ffihugs-option=-F'cpp -P -traditional -D__HUGS__ -D__BLAH__'

This requires duplicating the build specifications, which defeats
the point of Cabal. Also it leads to tricky issues about ensuring
the proper level of quoting/escaping. (e.g. using the plural,
--ffihugs-options=..., breaks it. Wrapping the -F'cpp...' in double
quotes breaks it.)

----------------------------------------------------------- fin.

Changes (2015-05-30):
0.3.7 (2013-08-08):
- System.Posix.IO.ByteString: Corrected a bug in fdSeek/tryFdSeek where the return value was always 0 on largefile i686 systems due to the underlying C function being (undocumentedly) implemented as a macrocall. This had been fixed in unix-, and I've just backported their fix (replacing the previous unix- implementation). Cf:
* <https://github.com/ghc/packages-base/blob/master/System/Posix/Internals.hs#L414>
* <https://github.com/ghc/packages-unix/blob/master/System/Posix/IO/Common.hsc#L306>
0.3.6 (2013-05-29):
- System.Posix.Types.Iovec: adjusted unsafeForeignPtrToPtr for GHC 7.8 (2012-08-23):
- System.Posix.IO.ByteString: adjusted some imports for GHC 7.6
- Removed the custom Setup.hs, for compatibility with GHC 7.6 (2012-02-21):
- Foreign.C.Error.Safe: changed (Num a) to (Eq a, Num a) for GHC 7.4
0.3.5 (2011-06-29):
- System.Posix.IO.ByteString: added fdSeek, tryFdSeek.
- Foreign.C.Error.Safe: added. (2011-04-03):
- LICENSE: corrected license for the fdReadBuf and fdWriteBuf functions
0.3.4 (2011-03-26):
- System.Posix.IO.ByteString.Lazy: Fixed functions to check (<=0) instead of (==0)
0.3.3 (2011-03-26):
- System.Posix.IO.ByteString: added tryFdReadBuf, tryFdReadvBuf, tryFdPreadBuf, tryFdWriteBuf, tryFdWritevBuf, tryFdPwriteBuf (2011-03-20):
- Changed the cabal category label to System
- Uploaded to Hackage
0.3.2 (2011-03-17):
- Removed the dependency on @unix@.
0.3.1 (2011-03-07):
- System.Posix.IO.ByteString: added fdPreads
- System.Posix.IO.ByteString.Lazy: added fdPread
0.3.0 (2011-03-07):
- System.Posix.IO.ByteString: added fdReadvBuf, exposed fdWritevBuf
- System.Posix.IO.ByteString: added fdReadBuf and fdWriteBuf for compatibility with older versions of the @unix@ package
- System.Posix.IO.ByteString: added fdPread, fdPreadBuf
- System.Posix.IO.ByteString: added fdPwrite, fdPwriteBuf

0.2.1 (2011-03-06):
- Added a custom build in order to define __HADDOCK__ when appropriate.
- System.Posix.IO.ByteString: added fdReads
0.2.0 (2011-03-05):
- Corrected the specifications (writev etc is XPG4.2, not POSIX)
- Added some extra #includes for legacy reasons
- Changed stability to experimental.
- Added new module System.Posix.Types.Iovec
- System.Posix.IO.ByteString.Lazy: added fdWritev
- System.Posix.IO.ByteString.Lazy: changed fdWrite to fdWrites
- System.Posix.IO.ByteString: added fdWrites and fdWritev
- Renamed package to unix-bytestring

0.1.0 (2011-02-27):
- Moved Data.ByteString.Posix to System.Posix.IO.ByteString
- Moved Data.ByteString.Lazy.Posix to System.Posix.IO.ByteString.Lazy

0.0.2 (2011-02-20):
- Fixed stack overflow possibility in Lazy.fdWrite
0.0.1 (2010-11-10):
- Added lazy variants
0.0.0 (2010-11-10):
- Initial version forked from Posta-IPC
Depends on:
Used by 4 packages:
comments powered byDisqus