{"id":16399203,"url":"https://github.com/klntsky/purescript-difference-containers","last_synced_at":"2026-03-03T04:36:09.589Z","repository":{"id":58235936,"uuid":"163538907","full_name":"klntsky/purescript-difference-containers","owner":"klntsky","description":"Difference lists.","archived":false,"fork":false,"pushed_at":"2019-09-18T06:38:26.000Z","size":427,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-02-23T04:30:22.336Z","etag":null,"topics":["dlist","functional-data-structure","purescript"],"latest_commit_sha":null,"homepage":"","language":"PureScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/klntsky.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-12-29T20:24:08.000Z","updated_at":"2019-09-18T06:37:39.000Z","dependencies_parsed_at":"2022-08-31T09:22:56.472Z","dependency_job_id":null,"html_url":"https://github.com/klntsky/purescript-difference-containers","commit_stats":null,"previous_names":["8084/purescript-difference-containers"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/klntsky/purescript-difference-containers","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klntsky%2Fpurescript-difference-containers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klntsky%2Fpurescript-difference-containers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klntsky%2Fpurescript-difference-containers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klntsky%2Fpurescript-difference-containers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/klntsky","download_url":"https://codeload.github.com/klntsky/purescript-difference-containers/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klntsky%2Fpurescript-difference-containers/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30032026,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-03T03:27:35.548Z","status":"ssl_error","status_checked_at":"2026-03-03T03:27:09.213Z","response_time":61,"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":["dlist","functional-data-structure","purescript"],"created_at":"2024-10-11T05:23:20.739Z","updated_at":"2026-03-03T04:36:09.574Z","avatar_url":"https://github.com/klntsky.png","language":"PureScript","readme":"# purescript-difference-containers\n\n[![Build status](https://travis-ci.org/klntsky/purescript-difference-containers.svg?branch=master)](https://travis-ci.org/klntsky/purescript-difference-containers)\n\n\"Difference containers\" is a name of this implementation of [difference lists](https://wiki.haskell.org/Difference_list). This library is usable with both `Data.List` and `Data.List.Lazy` (and potentially can be used with any list-like structure with `mempty` value and `append` operation).\n\n# Explanation\n\nSuppose there is a container type `cnt :: * -\u003e *` with associative operation `append :: ∀ a. cnt a -\u003e cnt a -\u003e cnt a`, the time complexity of which is dependent on the first argument's size and is constant for any size of the second.\n\nThen, a structure of form `append (append a b) c` is equivalent to the one of form `append a (append b c)`, but the latter requires less computations, because the size of `a` plus the size of `b` is generally less than the size of `a` plus the size of `append a b`.\n\nThis observation can be utilized for performance optimisation. It is possible to delay a computation that intensively appends to the right, and \"rebalance the parentheses\" before computing the final value.\n\nSee also: [R. John Muir Hughes, *A novel representation of lists and its application to the function ``reverse''*](https://www.cs.tufts.edu/%7Enr/cs257/archive/john-hughes/lists.pdf).\n\n# About this implementation\n\n- Instead of providing two types for strict and lazy difference lists, this library defines the `Difference` type, which is parametrised by the inner container type. `Difference List` is thus equivalent to [`DList` in Haskell](http://hackage.haskell.org/package/dlist).\n\n- For convenience, instances of `Functor`, `Apply`, `Bind`, `Monad`, `Foldable`, `Unfoldable` and `Traversable` type classes are provided for `Difference cnt` type if `cnt` is also an instance of the corresponding type class. However, their methods convert `Difference cnt` to `cnt` under the hood, so the benefits of employing this library may be defeated by their use.\n\n- To avoid stack safety issues, [purescript-stacksafe-function](https://github.com/safareli/purescript-stacksafe-function/) is used. It allows accumulating large number of functions using `compose` without hitting the stack size limit when actually running the resulting function.\n\n# Benchmarks\n\n![Append element to the end n times and get the last element](img/snoc.png)\n\n![Recursively duplicate list n times and get the last element](img/explode.png)\n\n![Append element to the beginning n times and get the last element](img/cons.png)\n\n# Documentation\n\nModule documentation is published on [Pursuit](https://pursuit.purescript.org/packages/purescript-difference-containers/).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fklntsky%2Fpurescript-difference-containers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fklntsky%2Fpurescript-difference-containers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fklntsky%2Fpurescript-difference-containers/lists"}