{"id":24865530,"url":"https://github.com/kfl/readbits","last_synced_at":"2025-03-26T18:44:46.658Z","repository":{"id":900842,"uuid":"656772","full_name":"kfl/readbits","owner":"kfl","description":"Example of how to read binary data with Haskell","archived":false,"fork":false,"pushed_at":"2010-06-04T14:26:11.000Z","size":100,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-31T23:59:58.039Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kfl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-05-08T18:53:39.000Z","updated_at":"2013-11-02T06:32:36.000Z","dependencies_parsed_at":"2022-08-06T10:01:15.367Z","dependency_job_id":null,"html_url":"https://github.com/kfl/readbits","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kfl%2Freadbits","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kfl%2Freadbits/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kfl%2Freadbits/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kfl%2Freadbits/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kfl","download_url":"https://codeload.github.com/kfl/readbits/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245717687,"owners_count":20661146,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-01T00:00:00.454Z","updated_at":"2025-03-26T18:44:46.626Z","avatar_url":"https://github.com/kfl.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"What is it?\n===========\n\nExample code showing how to use the ByteString library to work with binary data in Haskell. The code reads in a file as a ByteString, translate the ByteString to an internal datatype, `[Bit]`, transform the list of bits, re-packs it as a list of bytes, and write the list of bytes to a file. \n\nHow to build\n------------\nYou can either use cabal:\n\n    $ cabal configure\n    $ cabal build\n    $ ./dist/build/readbits-hs/readbits-hs infile outfile\n\nOr you can just use `ghc` directly:\n\n    $ ghc -O3 --make readbits.hs -o readbits-hs\n    $ ./readbits-hs infile outfile\n\nHow to profile\n--------------\nOne of points that code try to illustrate is how easy it is work with lazy steams. Thus, we write the code as if we read in the whole file, but due to laziness we only use constant memory independent of the size of the input file.\n\nHow can check that code really behaves as we intend? By using the space profiler:\n\n    $ ghc -O3 --make -prof -auto-all -caf-all readbits.hs -o readbits-hs\n    $ ./readbits-hs \u003cinfile\u003e \u003coutfile\u003e +RTS -hc -p\n    $ hp2ps -e8in -c readbits-hs.hp \u0026\u0026 open readbits-hs.ps\n\t\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkfl%2Freadbits","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkfl%2Freadbits","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkfl%2Freadbits/lists"}