{"id":23508733,"url":"https://github.com/lovasko/rset","last_synced_at":"2025-10-06T15:04:26.858Z","repository":{"id":56876902,"uuid":"97402276","full_name":"lovasko/rset","owner":"lovasko","description":"Range Set for Haskell","archived":false,"fork":false,"pushed_at":"2017-12-26T21:12:20.000Z","size":39,"stargazers_count":0,"open_issues_count":12,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-18T13:12:08.067Z","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":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lovasko.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2017-07-16T18:21:41.000Z","updated_at":"2017-07-21T11:21:41.000Z","dependencies_parsed_at":"2022-08-20T11:31:04.255Z","dependency_job_id":null,"html_url":"https://github.com/lovasko/rset","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovasko%2Frset","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovasko%2Frset/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovasko%2Frset/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovasko%2Frset/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lovasko","download_url":"https://codeload.github.com/lovasko/rset/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253970485,"owners_count":21992505,"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-12-25T11:31:51.274Z","updated_at":"2025-10-06T15:04:21.824Z","avatar_url":"https://github.com/lovasko.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Data.Set.Range\n[![Build Status](https://travis-ci.org/lovasko/rset.svg?branch=master)](https://travis-ci.org/lovasko/rset)\n\n## API\nThe module offers a wide spectrum of operations on a set of ranges, mostly\naiming at mimicking the existing API of the `Data.Set` module. All types\nhandled by the data structure have to be instances of the `Eq`, `Ord` and\n`Enum` typeclasses.\n\n### Types\nThe module consists of two main types: `Range` which is a alias for a tuple,\ndenoting the low and high _inclusive_ boundaries of the range, and the\n`RangeSet` type, which is an alias for a list of `Range` instances. The\n`RangeSet` type should be treated in a opaque fashion due to portability\nreasons, as it may become a `data` or `newtype` defined type in the future\nreleases of the module. Format definitions of the types mentioned above are:\n\n```haskell\ntype Range a    = (a,a)\ntype RangeSet a = [Range a]\n```\n\n### Functions\nAll provided functions can be divided into the following 5 categories: list\nconversions, combinations of multiple range sets, membership testing,\nmodifications of range set contents and general utility functions.\n\n#### `empty :: RangeSet a`\nCreate an empty range set.\n\n#### `null :: RangeSet a -\u003e Bool`\nTest whether the range set is empty.\n\n#### `size :: (Num n, Enum a) =\u003e RangeSet a -\u003e n`\nGet the overall number of points.\n\n#### `fromAscList :: (Ord a, Enum a) =\u003e [a] -\u003e RangeSet a`\nCreate a range set from a list of ascending points. \n\n#### `fromDescList :: (Ord a, Enum a) =\u003e [a] -\u003e RangeSet a`\nCreate a range set from a list of descending points.\n\n#### `fromList :: (Ord a, Enum a) =\u003e [a] -\u003e RangeSet a`\nCreate a range set from any list of points.\n\n#### `toList :: Enum a =\u003e RangeSet a -\u003e [a]`\nConvert a range set into list of points.\n\n#### `insertPoint :: (Ord a, Enum a) =\u003e a -\u003e RangeSet a -\u003e RangeSet a`\nInsert a point into the range set.\n\n#### `insertRange :: (Ord a, Enum a) =\u003e (a,a) -\u003e RangeSet a -\u003e RangeSet a`\nInsert a range into the range set.\n\n#### `removePoint :: (Ord a, Enum a) =\u003e a -\u003e RangeSet a -\u003e RangeSet a`\nRemove a point from the range set.\n\n#### `removeRange :: (Ord a, Enum a) =\u003e (a,a) -\u003e RangeSet a -\u003e RangeSet a`\nRemove a range from the range set.\n\n#### `queryPoint :: Ord a =\u003e a -\u003e RangeSet a -\u003e Bool`\nTest whether a point is part of the range set.\n\n#### `queryRange :: Ord a =\u003e (a,a) -\u003e RangeSet a -\u003e Bool`\nTest whether a range is part of the range set.\n\n#### `difference :: (Ord a, Enum a) =\u003e RangeSet a -\u003e RangeSet a -\u003e RangeSet a`\nSelect points contained only in the first range set.\n\n#### `intersect :: (Ord a, Enum a) =\u003e RangeSet a -\u003e RangeSet a -\u003e RangeSet a`\nSelect points contained in both of the range sets.\n\n#### `union :: (Ord a, Enum a) =\u003e RangeSet a -\u003e RangeSet a -\u003e RangeSet a`\nSelect points contained in either of the range sets.\n\n## Complexity\n\n| Function       | Time   | Space  |\n|:---------------|:-------|:-------|\n| `empty`        | O(*1*) | O(*1*) |\n| `null`         | O(*1*) | O(*1*) |\n| `size`         | O(*n*) | O(*l*) |\n| `fromAscList`  | O(*n*) | O(*n*) |\n| `fromDescList` | O(*n*) | O(*n*) |\n| `fromList`     | O(*n*) | O(*k*) |\n| `toList`       | O(*k*) | O(*n*) |\n| `insertPoint`  | O(*k*) | O(*1*) |\n| `insertRange`  | O(*k*) | O(*1*) |\n| `removePoint`  | O(*k*) | O(*1*) |\n| `removeRange`  | O(*k*) | O(*1*) |\n| `queryPoint`   | O(*k*) | O(*1*) |\n| `queryRange`   | O(*k*) | O(*1*) |\n| `difference`   | O(*k*) | O(*k*) |\n| `intersect`    | O(*k*) | O(*k*) |\n| `union`        | O(*k*) | O(*k*) |\n\n* *n* is the number of all points in the set\n* *k* is the number of distinct ranges in the set\n* *l* is the length of the largest range in the set\n\nGiven the example range set `[(1,4),(10,11)]` the variables above would be:\n* `n` is 6\n* `k` is 2\n* `l` is 4\n\n## Testing\nThe library is tested with the `QuickCheck` property testing library. All tests\nare using the set functions from the standard library module `Data.List` to\nverify the correctnes of `Data.Set.Range` functions. Moreover, the set of tests\nis executed after every push to the GitHub repository by the Travis continuous\nintegration service.\n\nThe most recent test coverage reported by HPC is as follows:\n```\n100% expressions used (468/468)\n 75% boolean coverage (12/16)\n      75% guards (12/16), 4 always True\n     100% 'if' conditions (0/0)\n     100% qualifiers (0/0)\n100% alternatives used (61/61)\n100% local declarations used (6/6)\n100% top-level declarations used (18/18)\n```\n\n## License\nThe `rset` package is licensed under the terms of the [2-clause BSD\nlicense](LICENSE). In case you need any other license, feel free to contact the\nauthor.\n\n## Author\nDaniel Lovasko \u003cdaniel.lovasko@gmail.com\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flovasko%2Frset","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flovasko%2Frset","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flovasko%2Frset/lists"}