{"id":17252056,"url":"https://github.com/ppetr/ordinal-list","last_synced_at":"2025-03-26T07:23:03.963Z","repository":{"id":146160483,"uuid":"407198505","full_name":"ppetr/ordinal-list","owner":"ppetr","description":"Infinite lists indexed by ordinal numbers","archived":false,"fork":false,"pushed_at":"2024-11-22T15:51:16.000Z","size":144,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-31T08:44:15.238Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ppetr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"docs/contributing.md","funding":null,"license":"LICENSE","code_of_conduct":"docs/code-of-conduct.md","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-09-16T14:34:15.000Z","updated_at":"2024-11-22T15:51:20.000Z","dependencies_parsed_at":"2023-05-01T16:03:29.324Z","dependency_job_id":null,"html_url":"https://github.com/ppetr/ordinal-list","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/ppetr%2Fordinal-list","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ppetr%2Fordinal-list/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ppetr%2Fordinal-list/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ppetr%2Fordinal-list/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ppetr","download_url":"https://codeload.github.com/ppetr/ordinal-list/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245606468,"owners_count":20643187,"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":"2024-10-15T06:52:56.171Z","updated_at":"2025-03-26T07:23:03.936Z","avatar_url":"https://github.com/ppetr.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Infinite lists indexed by [ordinals][1] up to ω\u003csup\u003eω\u003c/sup\u003e\n\n[1]: https://en.wikipedia.org/wiki/Ordinal_number\n\n_Status: Working implementation._\n\n_Disclaimer: This is not an official Google product._\n\n## Purpose\n\nIn some languages (like Haskell) it is possible to have infinite lists\n(sometimes also called _streams_). This experimental library extends the\nconcept to infinite lists indexed by ordinals beyond natural numbers, up to\nω\u003csup\u003eω\u003c/sup\u003e.\n\n![Illustration of ω\u003csup\u003eω\u003c/sup\u003e](https://upload.wikimedia.org/wikipedia/commons/a/af/Omega-exp-omega-normal-dark_svg.svg)\n\nPreserving the ordinal structure allows to examine even infinite portions of\nsuch lists. For example, with Haskell's regular [infinite lists][infinite] `xs\n++ ys` the `ys` part is forever lost (while still being kept in memory), there\nis no way to access it within a finite number of steps, or equivalently\nindexing the list with a natural number. But represented as an ordinal list\n(corresponding to _ω+ω_), it is possible to retrieve both infinite parts.\n\n[infinite]: https://en.wikibooks.org/wiki/Haskell/Lists_II#Infinite_Lists\n\n## Examples\n\nA finite list is also an ordinal list:\n```haskell\nghci\u003e fromFinite [1,2,3] :: OList Integer\n\u003c1,2,3\u003e\n```\nStreams, infinite lists, are also ordinal lists:\n```haskell\nghci\u003e omega = fromStream (S.iterate (+ 1) 0) :: OList Integer\nghci\u003e omega\n\u003c\u003c[0,1,2,3,...]\u003e\u003e\n```\nNote however that `fromFinite` won't accept an infinite `[a]` (it'll diverge).\nThe reason is that the structure - finite- or infinite-ness must be known when\nconstructing an ordinal list.\n\nInfinite ordinal lists can be concatenated and both parts are still available:\n```haskell\nghci\u003e omega \u003c\u003e omega\n\u003c\u003c[0,1,2,3,...],[0,1,2,3,...]\u003e\u003e\n```\nConcatenation also works with finite lists:\n```haskell\nghci\u003e fromFinite [42,73] \u003c\u003e omega \u003c\u003e omega\n\u003c\u003c[42,73,0,1,...],[0,1,2,3,...]\u003e\u003e\nghci\u003e omega \u003c\u003e omega \u003c\u003e fromFinite [42, 73]\n\u003c\u003c[0,1,2,3,...],[0,1,2,3,...]\u003e,42,73\u003e\n```\nFurthermore, ordinal lists can be multiplied together using the `Applicative`\ninterface.\n```haskell\nghci\u003e (*) \u003c$\u003e omega \u003c*\u003e fromFinite [1, -1]\n\u003c\u003c[0,1,2,3,...],[0,-1,-2,-3,...]\u003e\u003e\nghci\u003e (*) \u003c$\u003e fromFinite [1, -1] \u003c*\u003e omega\n\u003c\u003c[0,0,1,-1,...]\u003e\u003e\nghci\u003e (,) \u003c$\u003e omega \u003c*\u003e omega\n-- Indented for better readability:\n\u003c\u003c\u003c[[(0,0),(1,0),(2,0),(3,0),...],\n    [(0,1),(1,1),(2,1),(3,1),...],\n    [(0,2),(1,2),(2,2),(3,2),...],\n    [(0,3),(1,3),(2,3),(3,3),...],...]\u003e\u003e\u003e\nghci\u003e let o = omega \u003c\u003e fromFinite [-1] in (,) \u003c$\u003e o \u003c*\u003e o\n\u003c\u003c\u003c[[(0,0),(1,0),(2,0),(3,0),...],\n    [(-1,0),(0,1),(1,1),(2,1),...],\n    [(-1,1),(0,2),(1,2),(2,2),...],\n        [(-1,2),(0,3),(1,3),(2,3),...],...]\u003e,\n   [(0,-1),(1,-1),(2,-1),(3,-1),...]\u003e,(-1,-1)\u003e\n```\nOrdinals also can be compared, subtracted and zipped together. Function\n`zipSplit` implements all these operations in one:\n```haskell\ndata N.OListOrdering a b\n  = N.OListLT (OList1 b) | N.OListEQ | N.OListGT (OList1 a)\n\nzipSplit :: OList a -\u003e OList b -\u003e (OList (a, b), OListOrdering a b)\n```\nThe first result holds the ordinals zipped together (with the length of the\nsmaller ordinal), while the second result holds the result of the comparison\ntogether with the result of the subtraction.\n```haskell\nghci\u003e zipSplit (omega \u003c\u003e fmap (`subtract` 0) omega) (namedOrdinals S.!! 2)\n(\u003c\u003c[(0,\"0\"),(1,\"1\"),(2,\"2\"),(3,\"3\"),...],\n   [(0,\"ω\"),(-1,\"ω+1\"),(-2,\"ω+2\"),(-3,\"ω+3\"),...]\u003e\u003e,\n OListLT \u003c\u003c\u003c[[\"2ω\",\"2ω+1\",\"2ω+2\",\"2ω+3\",...],\n             [\"3ω\",\"3ω+1\",\"3ω+2\",\"3ω+3\",...],\n             [\"4ω\",\"4ω+1\",\"4ω+2\",\"4ω+3\",...],\n             [\"5ω\",\"5ω+1\",\"5ω+2\",\"5ω+3\",...],...]\u003e\u003e\u003e)\n```\nwhere `namedOrdinals` is a `Stream (OList String)` of ordinals, _i_-th listing\na human representation of ordinals up to ω\u003csup\u003ei\u003c/sup\u003e.\n\n## Contributions and future plans\n\nContributions welcome, please see [Code of Conduct](docs/code-of-conduct.md)\nand [Contributing](docs/contributing.md).\n\nSee \"TODO\" comments in the code.\n\nAt the moment ordinal lists are planned to support only concatenation\n(corresponding to [ordinal addition][operation]) and products (corresponding\nto [ordinal multiplication][operation]). Once these operations are finished,\nit might be possible to consider extending the concept to ordinal\nexponentiation as well, to lists indexed by ordinals up to [ε₀][epsilon]. In\ncase of interest please open a feature request on the project's GitHub page.\n\n[operation]: https://en.wikipedia.org/wiki/Ordinal_arithmetic\n[epsilon]: https://en.wikipedia.org/wiki/Epsilon_numbers_(mathematics)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fppetr%2Fordinal-list","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fppetr%2Fordinal-list","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fppetr%2Fordinal-list/lists"}