{"id":13709567,"url":"https://github.com/purescript-contrib/purescript-rationals","last_synced_at":"2026-03-09T19:36:59.237Z","repository":{"id":36291278,"uuid":"40595807","full_name":"purescript-contrib/purescript-rationals","owner":"purescript-contrib","description":"Rational numbers for PureScript","archived":false,"fork":false,"pushed_at":"2024-06-27T18:27:01.000Z","size":66,"stargazers_count":13,"open_issues_count":2,"forks_count":13,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-02-11T16:43:53.953Z","etag":null,"topics":["purescript"],"latest_commit_sha":null,"homepage":null,"language":"PureScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/purescript-contrib.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","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":"2015-08-12T10:53:12.000Z","updated_at":"2024-06-27T18:27:05.000Z","dependencies_parsed_at":"2024-05-08T00:45:01.541Z","dependency_job_id":null,"html_url":"https://github.com/purescript-contrib/purescript-rationals","commit_stats":null,"previous_names":["anttih/purescript-rationals"],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purescript-contrib%2Fpurescript-rationals","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purescript-contrib%2Fpurescript-rationals/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purescript-contrib%2Fpurescript-rationals/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purescript-contrib%2Fpurescript-rationals/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/purescript-contrib","download_url":"https://codeload.github.com/purescript-contrib/purescript-rationals/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242635336,"owners_count":20161437,"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":["purescript"],"created_at":"2024-08-02T23:00:41.501Z","updated_at":"2026-01-11T04:05:02.553Z","avatar_url":"https://github.com/purescript-contrib.png","language":"PureScript","funding_links":[],"categories":["Maths"],"sub_categories":[],"readme":"# Rationals\n\n[![CI](https://github.com/purescript-contrib/purescript-rationals/workflows/CI/badge.svg?branch=master)](https://github.com/purescript-contrib/purescript-rationals/actions?query=workflow%3ACI+branch%3Amaster)\n[![Release](https://img.shields.io/github/release/purescript-contrib/purescript-rationals.svg)](https://github.com/purescript-contrib/purescript-rationals/releases)\n[![Pursuit](https://pursuit.purescript.org/packages/purescript-rationals/badge)](https://pursuit.purescript.org/packages/purescript-rationals)\n[![Maintainer: gbagan](https://img.shields.io/badge/maintainer-gbagan-teal.svg)](https://github.com/gbagan)\n\nUsing numbers to do arithmetic with fractions in PureScript may yield surprising results:\n\n```\n\u003e 0.1 + 0.2\n0.30000000000000004\n```\n\nThe same can be expressed accurately with `Rational` using the `(%)` operator:\n\n```\n\u003e import Data.Rational\n\u003e (1 % 10) + (2 % 10)\n3 % 10\n```\n\nYou can turn a `Rational` to a `Number`:\n\n```\n\u003e toNumber (3 % 10)\n0.3\n```\n\n## Installation\n\nInstall `rationals` with [Spago](https://github.com/purescript/spago):\n\n```sh\nspago install rationals\n\n# Or with Bower\nbower install purescript-rationals\n```\n\n## Other Ratios\n\n`Rational` is just a newtype over `Ratio BigInt` and you might want to use\n`Ratio` with other than `BigInt`. The type you choose must however be an `EuclideanRing`.\n\n```\n\u003e import Data.Ratio ((%), reduce)\n\u003e import Data.BigInt (fromInt, fromString)\n\u003e :type fromInt 1 % fromInt 3\nRatio BigInt\n\u003e reduce \u003c$\u003e fromString \"10\" \u003c*\u003e fromString \"857981209301293808359384092830482\"\n(Just fromString \"5\" % fromString \"428990604650646904179692046415241\")\n```\n\n## Documentation\n\n`rationals` documentation is stored in a few places:\n\n1. Module documentation is [published on Pursuit](https://pursuit.purescript.org/packages/purescript-rationals).\n2. Usage examples can be found in [the test suite](./test).\n\nIf you get stuck, there are several ways to get help:\n\n- [Open an issue](https://github.com/purescript-contrib/purescript-rationals/issues) if you have encountered a bug or problem.\n- Ask general questions on the [PureScript Discourse](https://discourse.purescript.org) forum or the [PureScript Discord](https://discord.com/invite/sMqwYUbvz6) chat.\n\n## Contributing\n\nYou can contribute to `rationals` in several ways:\n\n1. If you encounter a problem or have a question, please [open an issue](https://github.com/purescript-contrib/purescript-rationals/issues). We'll do our best to work with you to resolve or answer it.\n\n2. If you would like to contribute code, tests, or documentation, please [read the contributor guide](./CONTRIBUTING.md). It's a short, helpful introduction to contributing to this library, including development instructions.\n\n3. If you have written a library, tutorial, guide, or other resource based on this package, please share it on the [PureScript Discourse](https://discourse.purescript.org)! Writing libraries and learning resources are a great way to help this library succeed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpurescript-contrib%2Fpurescript-rationals","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpurescript-contrib%2Fpurescript-rationals","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpurescript-contrib%2Fpurescript-rationals/lists"}