{"id":17729285,"url":"https://github.com/athanclark/sets","last_synced_at":"2026-02-04T02:38:34.486Z","repository":{"id":35524904,"uuid":"39795566","full_name":"athanclark/sets","owner":"athanclark","description":"Sets in Haskell.","archived":false,"fork":false,"pushed_at":"2019-10-27T17:59:22.000Z","size":3823,"stargazers_count":0,"open_issues_count":4,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-14T09:00:05.143Z","etag":null,"topics":["haskell","newtype","overloaded-terms","typeclasses"],"latest_commit_sha":null,"homepage":null,"language":"HTML","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/athanclark.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":"2015-07-27T20:11:06.000Z","updated_at":"2019-10-27T17:59:25.000Z","dependencies_parsed_at":"2022-09-08T20:31:57.055Z","dependency_job_id":null,"html_url":"https://github.com/athanclark/sets","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/athanclark/sets","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/athanclark%2Fsets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/athanclark%2Fsets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/athanclark%2Fsets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/athanclark%2Fsets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/athanclark","download_url":"https://codeload.github.com/athanclark/sets/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/athanclark%2Fsets/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259968982,"owners_count":22939761,"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":["haskell","newtype","overloaded-terms","typeclasses"],"created_at":"2024-10-25T21:06:19.931Z","updated_at":"2026-02-04T02:38:34.460Z","avatar_url":"https://github.com/athanclark.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"sets\n====\n\nThis package provides overloaded terms, commonly used with set-like types,\nlike `Map` and `Set` from `containers`. There are also unorthodox, mostly useless\ndata types defined here - playing with ordering, uniqueness and finiteness.\n\n## Usage\n\nThe following actions are overloaded:\n\n__Binary Operators__:\n\n- `union`\n- `intersection`\n- `difference`\n- `complement`\n\n__Top and Bottom Elements__:\n\n- `empty`\n- `total`\n\n__Element-Wise Operations__:\n\n- `singleton`\n- `insert`\n- `delete`\n\n__Metrics and Comparison__:\n\n- `size`\n- `isSubsetOf` `isProperSubsetOf`\n\n---\n\nEach of the operations has their own typeclass. We have also made newtype wrappers\nfor lists, for different restrictions:\n\n- Ordered Sets\n    - Multiple\n- Unordered Sets\n    - Unique\n    - Multiple\n\nThis way, we can expect the following to work:\n\n```haskell\nuniqueAppend :: Eq a =\u003e [a] -\u003e [a] -\u003e [a]\nuniqueAppend xs ys = unUUSet $ fromFoldable xs `union` fromFoldable ys\n\norderedAppend :: Ord a =\u003e [a] -\u003e [a] -\u003e [a]\norderedAppend xs ys = unOMSet $ fromFoldable xs `union` fromFoldable ys\n```\n\n---\n\nWe've also made a few newtypes to encode our binary operations, for `Monoid`\nand `Semigroup` instances:\n\n```haskell\ninstance (HasUnion s, HasEmpty s) =\u003e Monoid (Union s) where\n  mempty = empty\n  mappend = union\n```\n\n### Multiple Set Types\n\nTo use the overloaded terms, they need to be the only ones in scope. To make this\ncorrect, we need to import our container with caution:\n\n```haskell\nimport qualified Data.Set as Set\nimport Data.Map (Map) -- only the type name to designate behavior\n\nfoo :: Map\nfoo = x `union` y\n\nbar :: Set.Set\nbar = a `union` b\n```\n\nThis way, we can keep our code more readable while still having set-like intuition.\n\n## Testing and Benchmarking\n\n\u003e You can view the results [here](https://github.com/athanclark/sets/raw/master/profile.html)\n\u003e (__warning__: it's a 7MB text file - your browser will hate you)\n\nThe tests are built with QuickCheck - it's pretty easy to get them working for you:\n\n```bash\ncabal install --enable-tests\ncabal test --show-details=always\n```\n\n(...or for the stack folk...)\n\n```bash\nstack build\nstack test\n```\n\n---\n\nTo benchmark (it usually takes about 10 minutes on my laptop), run the command!\n\n```bash\ncabal install --enable-benchmarks\ncabal bench\n```\n\n(...stiggitty-stack is co-wiggity-whack...)\n\n```bash\nstack build\nstack bench --benchmark-arguments=\"--output profile.html\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fathanclark%2Fsets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fathanclark%2Fsets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fathanclark%2Fsets/lists"}