byteslice: Slicing managed and unmanaged memory

[ bsd3, data, library ] [ Propose Tags ]

This library provides types that allow the user to talk about a slice of a ByteArray or a MutableByteArray. It also offers UnmanagedBytes, which is kind of like a slice into unmanaged memory. However, it is just an address and a length.

[Skip to Readme]


Automatic Flags

Avoid using rawmemchr which is non-portable GNU libc only


Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info


Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


  • No Candidates
Versions [RSS],,,,,,,,,,,,,,,,,,,,,,, (info)
Change log
Dependencies base (>=4.14 && <5), bytestring (>=0.10.8 && <0.13), natural-arithmetic (>=0.1.4), primitive (>=0.7.4 && <0.10), primitive-addr (>=0.1 && <0.2), primitive-unlifted (>=0.1.2 && <2.2), run-st (>=0.1.1 && <0.2), text (>=1.2.5), text-short (>=0.1.3 && <0.2), tuples (>=0.1 && <0.2), vector (>=0.12 && <0.14) [details]
License BSD-3-Clause
Copyright 2020 Andrew Martin
Author Andrew Martin
Category Data
Home page
Bug tracker
Source repo head: git clone git://
Uploaded by l3c_amartin at 2024-02-07T14:18:59Z
Distributions LTSHaskell:, NixOS:, Stackage:
Reverse Dependencies 36 direct, 88 indirect [details]
Downloads 9417 total (103 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for byteslice-

[back to package description]



Types for dealing with slices of 'ByteArray' and 'MutableByteArray'. These are never supposed to introduce overhead. Rather, they exist to clarify intent in type signatures.

receive ::
     Resource -- ^ Some scarce resource
  -> MutableByteArray RealWorld -- ^ Buffer
  -> Int -- ^ Offset
  -> Int -- ^ Length
  -> IO ()

With this library, we instead write

receive ::
     Resource -- ^ Some scarce resource
  -> MutableBytes RealWorld -- ^ Buffer
  -> IO ()

The combination of the worker-wrapper transformation and inlining means that we can expect these two to end up generating the same code in most situations.