Parsing Bits with Haskell

In some old code I used binary-bits to parse individual bits.

Here I see a tutorial using binary-strict.

Both libraries are marked as ‘broken’ in Nix (my code with binary-bits still compiles using Stack though).

Any suggestions on parsing bits in Haskell nowadays? (preferably with Nix)

1 Like

Nixpkgs marking things as broken is often a bounds issue, and if the package has since been fixed, you can PR .../configuration-hackage2nix/broken.yaml to unmark it as broken for everyone. PR the haskell-updates branch, because they batch regenerations of hackage2nix to avoid too many rebuilds on the main branch.

An easy way to test if a package could be unmarked as broken is to run a command like NIXPKGS_ALLOW_BROKEN=1 nix-build --no-link -A haskellPackages.binary-bits:

  • binary-bits fails to build because its base bound is too tight. If it can be raised you can fix the package and/or ask for a metadata revision on Hackage. The function nixpkgs.haskell.lib.doJailbreak will also remove many bounds, but in this case binary-bits fails to compile because it assumes fail is a member of class Monad.
  • binary-strict has bounds issues, and jailbreaking it fails because of missing ByteString-related functions; I suspect it was never updated.

I don’t know what packages you’d actually use for this, but I hope the nixpkgs/haskell information is at least somewhat useful.

3 Likes

It looks like this is the way to go now: GitHub - tfausak/caerbannog: 🐰 That rabbit's got a vicious streak a mile wide! (a fork of the original ‘binary-bits’ package)

Also, it works with NixPkgs.

Unfortunately it is also not maintained.

@taylorfausak: Big thanks in any case! : ) V helpful.

Also, @jackdk thanks for helping out on the Nix side - this will be very helpful for me in future!

1 Like