{"id":19427161,"url":"https://github.com/morphismtech/distributors","last_synced_at":"2025-04-30T06:27:20.475Z","repository":{"id":215115992,"uuid":"737118300","full_name":"morphismtech/distributors","owner":"morphismtech","description":"Distributors - lax distributive endoprofunctors for unifying grammars, printers and parsers","archived":false,"fork":false,"pushed_at":"2025-02-20T21:44:16.000Z","size":311,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-02-20T22:30:39.379Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/morphismtech/distributors","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/morphismtech.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"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":"2023-12-29T21:56:36.000Z","updated_at":"2025-02-20T21:44:19.000Z","dependencies_parsed_at":"2025-02-20T22:26:31.996Z","dependency_job_id":"830179cc-20a0-4dd7-b08e-abd75c7887ce","html_url":"https://github.com/morphismtech/distributors","commit_stats":null,"previous_names":["morphismtech/distributors"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morphismtech%2Fdistributors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morphismtech%2Fdistributors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morphismtech%2Fdistributors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morphismtech%2Fdistributors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/morphismtech","download_url":"https://codeload.github.com/morphismtech/distributors/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240605848,"owners_count":19827985,"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-11-10T14:10:38.848Z","updated_at":"2025-04-30T06:27:20.470Z","avatar_url":"https://github.com/morphismtech.png","language":"Haskell","readme":"# Distributors\n## Unifying Parsers, Printers \u0026 Grammars\n\n[![GithubWorkflowCI](https://github.com/morphismtech/distributors/actions/workflows/ci.yml/badge.svg)](https://github.com/morphismtech/distributors/actions/workflows/ci.yml)\n\n\nThis library provides mathematically inspired abstractions for coders to write parsers that can also be inverted to printers.\n\n## introduction\nThe term \"distributor\" is a synonym for \"[profunctor](https://ncatlab.org/nlab/show/profunctor)\". Jean Bénabou who invented the term and originally used “profunctor,” then preferred “[distributor](http://www.entretemps.asso.fr/maths/Distributors.pdf)”, which is supposed to carry the intuition that a distributor generalizes a functor in a similar way to how a distribution generalizes a function.\n\n[Bénabou](http://cahierstgdc.com/wp-content/uploads/2022/07/F.-BORCEUX-LXIII-3.pdf) in his time introduced the notions of enriched categories, bicategories as well as distributors and invented the term monad. He was lost to us on 11, February 2022 and this library is dedicated to his memory.\n\nSince \"profunctor\" became the standard nomenclature, we reappropriate \"distributor\" to describe a profunctor on a [distributive category](https://ncatlab.org/nlab/show/distributive+category).\n\nThis library provides a study of `Monoidal` profunctors, `Distributor`s, `Alternator`s and `Filtrator`s. These profunctor constraints are analogous to `Applicative`, `Alternative` and `Filterable` functors. Examples of `Distributor`s will include printers and parsers, and it is demonstrated how to write a single term for both. Profunctors naturally give rise to optics and this library also studies some previously discovered optics, `PartialIso`s, `Monocle`s, `Grate`s and `Wither`s and also defines new optics, `Diopter`s and `Bifocal`s. Finally, an application of distributors is demonstrated by unifying Backus-Naur form grammars with invertible parsers, giving users a powerful playground for front-end language design.\n\n## previous work\n\nThe results concerning invertible parsers are a profunctorial interpretation of [Invertible Syntax Descriptions](https://www.mathematik.uni-marburg.de/~rendel/rendel10invertible.pdf) by Tillman Rendel \u0026 Klaus Ostermann.\n\nWhile `Distributor`s in the library are lax distributive endoprofunctors, a mathematical treatment of strong (i.e. with invertible structure morphisms) distributors is given by Travis Squires in [Profunctors and Distributive Categories](https://central.bac-lac.gc.ca/.item?id=MR31635).\n\nThe idea for unifying Backus-Naur grammars with parsers comes from Joachim Breitner in a post [Showcasing Applicative](https://www.joachim-breitner.de/blog/710-Showcasing_Applicative).\n\nThe person deserving the most credit for bringing the power of optics to programming, with his [lens library](https://github.com/ekmett/lens/), is Ed Kmett, to whom I am very grateful for teaching me a lot.\n\nNone of the ideas in this library are particularly original and a lot of related ideas have been explored, in Tom Ellis' [product-profunctors](https://github.com/tomjaguarpaw/product-profunctors) as well as Sjoerd Visscher's [one-liner](https://github.com/sjoerdvisscher/one-liner) and more. Such explorations are _not_ limited to Haskell. Brandon Williams and Stephen Celis' excellent [swift-parsing](https://github.com/pointfreeco/swift-parsing) was also influenced by invertible parser theory.\n\nSome optics in this library are [grates, a new kind of optic](https://r6research.livejournal.com/28050.html), discovered by Russel O'Connor and James Deikun; monocles which are studied by Alexandre Garcia de Oliveira, Mauro Jaskelioff, and Ana Cristina Vieira de Melo in [On Structuring Functional Programs with Monoidal Profunctors](https://arxiv.org/abs/2207.00852); and withers, discovered by Chris Penner in [Composable filters using Witherable optics](https://chrispenner.ca/posts/witherable-optics).\n\n## contributing\n\nContributors are welcome. The [Issues](https://github.com/morphismtech/distributors/issues) page is a good place to communicate.\n","funding_links":[],"categories":["Haskell"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorphismtech%2Fdistributors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmorphismtech%2Fdistributors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorphismtech%2Fdistributors/lists"}