{"id":13709492,"url":"https://github.com/sigma-andex/purescript-fast-vect","last_synced_at":"2026-01-12T07:41:51.182Z","repository":{"id":40249126,"uuid":"376387243","full_name":"sigma-andex/purescript-fast-vect","owner":"sigma-andex","description":"Fast 🐆, type-safe vectors for Purescript","archived":false,"fork":false,"pushed_at":"2023-12-10T10:05:13.000Z","size":992,"stargazers_count":25,"open_issues_count":6,"forks_count":5,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-02T06:43:39.020Z","etag":null,"topics":["dependent-types"],"latest_commit_sha":null,"homepage":"","language":"PureScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit-0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sigma-andex.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-12T21:32:27.000Z","updated_at":"2025-01-17T10:27:36.000Z","dependencies_parsed_at":"2024-05-08T00:32:05.586Z","dependency_job_id":"5ada8d03-89a1-4427-8ab8-b93751071861","html_url":"https://github.com/sigma-andex/purescript-fast-vect","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/sigma-andex/purescript-fast-vect","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sigma-andex%2Fpurescript-fast-vect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sigma-andex%2Fpurescript-fast-vect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sigma-andex%2Fpurescript-fast-vect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sigma-andex%2Fpurescript-fast-vect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sigma-andex","download_url":"https://codeload.github.com/sigma-andex/purescript-fast-vect/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sigma-andex%2Fpurescript-fast-vect/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28336656,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T06:09:07.588Z","status":"ssl_error","status_checked_at":"2026-01-12T06:05:18.301Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["dependent-types"],"created_at":"2024-08-02T23:00:40.200Z","updated_at":"2026-01-12T07:41:51.160Z","avatar_url":"https://github.com/sigma-andex.png","language":"PureScript","funding_links":[],"categories":["Data types"],"sub_categories":[],"readme":"# purescript-fast-vect 🐆\n\nFast, type-safe vector libary for Purescript inspired by [Idris](https://www.idris-lang.org/). A vector is list with its size encoded in the type.\n\n## TOC\n- [Installation](#installation)\n- [Long story](#long-story)\n- [Example usage](#example-usage)\n- [Contributors](#contributors)\n\n## Installation\n\n```bash\nspago install fast-vect\n```\n\n## Long story\n\nA vector is a list (or an Array in the case of Purescript) that has its size encoded in the type. For instance in Idris you can define a vector like this:\n\n```idris \nvect : Vect 3 Int \nvect = [1,2,3]\n```\n\nNote the value `3` in the type position, indicating that the vector has exactly three elements.\n\nIn `purescript-fast-vect` we can define the same three element vector like this:\n\n```purescript \nvect :: Vect 3 Int\nvect = 1 : 2 : 3 : empty\n```\n\nWhat is this good for you ask? Well, now that we have the size encoded in the type, the compiler can help us find errors. For instance, the compiler can tell us when we try to access the head of an empty list. \n\nThis leads to a slightly different design of the api. E.g. the `head` function in `Data.Array` has the following type signature:\n```purescript\nhead :: forall a. Array a -\u003e Maybe a\n```\nSo if you call head on an `Array`, you have to handle the `Maybe`. \nIn contrast, `head` in `Data.FastVect` has the following type signature (conceptually - the real one is slightly more complex) :\n```purescript\nhead :: forall m elem. Vect m elem -\u003e elem\n```\nYou will get an `elem` back, no need to handle a `Maybe`. And this operation is always safe, because in the case that the vector is empty you will get a compile-time error. \n\nSimilarly, the `index` function has the following type signature (conceptually - the real one is slightly more complex):\n```purescript\nindex :: forall i m elem. Term i -\u003e Vect m elem -\u003e elem\n```\nIf the index `i` (represented as a typelevel symbol) is in bounds, i.e. `i \u003c m`, you will get an `elem` back, otherwise you will get a compile-time error. \n\nFurther functions that are defined differently to the `Array` functions are:\n\n* `take` is guaranteed to return you a vector with the number of elements requested and result in a compile-time error if you are trying to request more elements than are in the vector. \n* `drop` is guaranteed to drop the exact number of elements from the vector and result in a compile-time error if you are trying to drop more elements than exist in the vector.\n\nYou can find the full api on [pursuit](https://pursuit.purescript.org/packages/purescript-fast-vect/docs/Data.FastVect.FastVect). \n\n## Example usage \n\n```purescript\nimport Prelude\n\nimport Data.FastVect.FastVect (Vect)\nimport Data.FastVect.FastVect as FV\nimport Typelevel.Arithmetic.Add (Term, term)\n\nas :: Vect 300 String\nas = FV.replicate (term :: Term 300) \"a\"\n-- Note you could also leave out the Term type annotation, as PS can infer it:\n-- as = FV.replicate (term :: _ 300) \"a\"\n\nbs :: Vect 200 String\nbs = FV.replicate (term :: Term 200) \"b\"\n\ncs :: Vect 500 String\ncs = FV.append as bs\n\nds :: Vect 2 String\nds = cs # FV.drop (term :: Term 299) # FV.take (term :: Term 2)\n\nx :: String\nx = FV.index (term :: Term 499) cs\n\ny :: String\ny = FV.head (FV.singleton \"a\")\n\nbig1 :: Vect 23923498230498230420 String\nbig1 = FV.replicate (term :: Term 23923498230498230420) \"a\"\n\nbig2 :: Vect 203948023984590684596840586 String\nbig2 = FV.replicate (term :: Term 203948023984590684596840586) \"b\"\n\nbig :: Vect 203948047908088915095071006 String\nbig = FV.append big1 big2\n-- Note the big example will blow up during runtime.\n```\n\n## Contributors\n\nIn order of contribution:\n- [@sigma-andex](https://github.com/sigma-andex)\n- [@mikesol](https://github.com/mikesol)\n- [@JamieBallingall](https://github.com/JamieBallingall)\n- [@yukikurage](https://github.com/yukikurage)\n- [@artemisSystem](https://github.com/artemisSystem)\n- [@albertprz](https://github.com/albertprz)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsigma-andex%2Fpurescript-fast-vect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsigma-andex%2Fpurescript-fast-vect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsigma-andex%2Fpurescript-fast-vect/lists"}