{"id":13800561,"url":"https://github.com/rowtype-yoga/purescript-parsing-dataview","last_synced_at":"2026-01-18T17:33:54.695Z","repository":{"id":45959185,"uuid":"243145109","full_name":"rowtype-yoga/purescript-parsing-dataview","owner":"rowtype-yoga","description":"DataView on ArrayBuffer input stream support for purescript-parsing","archived":false,"fork":false,"pushed_at":"2022-12-05T00:04:37.000Z","size":106,"stargazers_count":5,"open_issues_count":3,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-08T03:06:11.925Z","etag":null,"topics":["arraybuffer","parsing","purescript","purescript-parsing"],"latest_commit_sha":null,"homepage":"https://pursuit.purescript.org/packages/purescript-parsing-dataview","language":"PureScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rowtype-yoga.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-02-26T01:59:01.000Z","updated_at":"2024-11-04T08:05:20.000Z","dependencies_parsed_at":"2023-01-23T00:45:59.451Z","dependency_job_id":null,"html_url":"https://github.com/rowtype-yoga/purescript-parsing-dataview","commit_stats":null,"previous_names":["jamesdbrock/purescript-parsing-dataview"],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rowtype-yoga%2Fpurescript-parsing-dataview","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rowtype-yoga%2Fpurescript-parsing-dataview/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rowtype-yoga%2Fpurescript-parsing-dataview/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rowtype-yoga%2Fpurescript-parsing-dataview/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rowtype-yoga","download_url":"https://codeload.github.com/rowtype-yoga/purescript-parsing-dataview/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253913189,"owners_count":21983273,"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":["arraybuffer","parsing","purescript","purescript-parsing"],"created_at":"2024-08-04T00:01:13.738Z","updated_at":"2026-01-18T17:33:54.666Z","avatar_url":"https://github.com/rowtype-yoga.png","language":"PureScript","funding_links":[],"categories":["Binary Serialization"],"sub_categories":[],"readme":"# purescript-parsing-dataview\n\n[![CI](https://github.com/rowtype-yoga/purescript-parsing-dataview/workflows/CI/badge.svg?branch=master)](https://github.com/rowtype-yoga/purescript-parsing-dataview/actions)\n[![Pursuit](http://pursuit.purescript.org/packages/purescript-parsing-dataview/badge)](http://pursuit.purescript.org/packages/purescript-parsing-dataview/)\n[![Maintainer: jamesdbrock](https://img.shields.io/badge/maintainer-jamesdbrock-teal.svg)](https://github.com/jamesdbrock)\n\nPrimitive parsers for\n`DataView`s on JavaScript `ArrayBuffer`s with the package\n[__parsing__](https://pursuit.purescript.org/packages/purescript-parsing/).\n\nWith this package, the input stream support of __parsing__\nis similar to the built-in stream support of [__Megaparsec__](https://hackage.haskell.org/package/megaparsec):\n\n| Stream type | parsing | Megaparsec |\n|----|-----|----|\n| UTF-16 strings | String | Text \u003c v2.0|\n| UTF-8 strings | __DataView__ | Text ≥ v2.0 |\n| Listy strings | Token | String |\n| Binary blobs | __DataView__ | ByteString |\n\n## Usage examples\n\nParse values out of a `dataview :: Data.ArrayBuffer.Types.DataView`. All\n`DataView` parsing must be done in an `Effect` context. The `result` will be\n`Either` a parse error or the parsed value.\n\n### Parse two numbers\n\nParse two big-endian IEEE 754 double-precision `Number`s.\n\n```purescript\nimport Parsing (runParserT)\nimport Parsing.DataView (anyFloat64be)\n\ndo\n  result \u003c- runParserT dataview do\n    float1 \u003c- anyFloat64be\n    float2 \u003c- anyFloat64be\n    pure $ Tuple float1 float2\n```\n\n### Parse an array\n\nParse an array of `n` 32-bit big-endian signed `Int`s.\n\n```purescript\nimport Parsing (runParserT)\nimport Parsing.DataView (anyUint32be)\nimport Data.Unfoldable (replicateA)\n\ndo\n  result \u003c- runParserT dataview $ replicateA n anyInt32be\n```\n\n### Parse UTF-8\n\nParse a UTF-8 `String` with a length prefix.\n\nWe give this as an example, rather than supporting it in the library, because\nit depends on\n[__web-encoding__](https://pursuit.purescript.org/packages/purescript-web-encoding) for UTF-8.\n\n```purescript\nimport Control.Monad.Except (ExceptT)\nimport Data.ArrayBuffer.Cast (toUint8Array)\nimport Effect.Exception (catchException, message)\nimport Parsing (runParserT, liftExceptT)\nimport Parsing.DataView (anyInt32be, takeN)\nimport Web.Encoding.TextDecoder as TextDecoder\nimport Web.Encoding.UtfLabel as UtfLabel\n\ndo\n  textDecoder \u003c- TextDecoder.new UtfLabel.utf8\n\n  result \u003c- runParserT dataview do\n    -- First parse a 32-bit big-endian length prefix for the length\n    -- of the UTF-8 string in bytes.\n    length      \u003c- anyInt32be\n    stringview  \u003c- takeN length\n    stringarray \u003c- lift $ liftEffect $ toUint8Array stringview\n    liftExceptT $ ExceptT $ catchException (pure \u003c\u003c\u003c Left \u003c\u003c\u003c message) do\n      Right \u003c$\u003e TextDecoder.decode stringarray textDecoder\n```\n\n## Serialization\n\nThis package is for reading (`DataView`s on) `ArrayBuffer`s, not writing\nthem. See the package\n[__arraybuffer-builder__](https://pursuit.purescript.org/packages/purescript-arraybuffer-builder/)\nfor a way to\nserialize and build `ArrayBuffer`s.\n\n\n## References\n\n* [MDN `ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)\n* [MDN `DataView`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView)\n\n## Development\n\nRun the tests with the development `spago` file:\n\n```\nspago -x spago-dev.dhall test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frowtype-yoga%2Fpurescript-parsing-dataview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frowtype-yoga%2Fpurescript-parsing-dataview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frowtype-yoga%2Fpurescript-parsing-dataview/lists"}