{"id":47422456,"url":"https://github.com/cando/Algar","last_synced_at":"2026-04-04T22:01:14.476Z","repository":{"id":65337313,"uuid":"590095540","full_name":"cando/Algar","owner":"cando","description":"Algebraic structures, higher-kinded types and other category theory bad ideas","archived":false,"fork":false,"pushed_at":"2023-03-31T15:57:24.000Z","size":60,"stargazers_count":23,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-18T05:27:21.459Z","etag":null,"topics":["category-theory","functional-programming","monad-transformers","monads"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/cando.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":"2023-01-17T16:42:16.000Z","updated_at":"2025-08-30T13:06:33.000Z","dependencies_parsed_at":"2023-02-19T09:31:15.648Z","dependency_job_id":null,"html_url":"https://github.com/cando/Algar","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/cando/Algar","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cando%2FAlgar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cando%2FAlgar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cando%2FAlgar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cando%2FAlgar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cando","download_url":"https://codeload.github.com/cando/Algar/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cando%2FAlgar/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31416324,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-04T20:09:54.854Z","status":"ssl_error","status_checked_at":"2026-04-04T20:09:44.350Z","response_time":60,"last_error":"SSL_read: 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":["category-theory","functional-programming","monad-transformers","monads"],"created_at":"2026-03-21T17:00:28.994Z","updated_at":"2026-04-04T22:01:14.467Z","avatar_url":"https://github.com/cando.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# Algar\n\n[![Crates.io][crates-badge]][crates-url]\n[![Build][actions-badge]][actions-url]\n[![docs-badge]][docs-url]\n\n[crates-badge]: https://img.shields.io/crates/v/algar.svg\n[crates-url]: https://crates.io/crates/algar\n[actions-badge]: https://img.shields.io/github/actions/workflow/status/cando/Algar/rust.yml\n[actions-url]: https://github.com/cando/Algar/actions?query=branch%3Amain\n[docs-badge]: https://img.shields.io/docsrs/algar?color=green\n[docs-url]: https://docs.rs/algar/\n\nAlgebric structures, higher-kinded types and other category theory bad ideas.\n\nYes, you'll have generalized `functors`, `applicatives`, `monads`, `traversable`, `free monads` and much more in Rust at your fingertips. \nBut no, they're not as ergonomic and beautiful as in Haskell, mainly because of the lack of higher-kinded types in Rust type-system.\n\nIn the examples section you'll also find my take on solving the expression problem in Rust: we start from a basic (wrong) implementation and then work towards a solution by trying to implement `coproduct of functors` and `final tagless encoding`.\n\n## Why?\n\nI wrote this library for two reasons: first, mainly as a playground for learning *Category Theory* and *Rust*, second to see if it was even possible to\nimplement such general abstract nonsense in Rust.\n\n## Does category theory make you a better programmer ?\n\nI think it does. Category theory centers around *abstraction* and *composition* and I will argue strongly that abstraction and composition are the essence of programming.\n\n### Abstraction\n\nAbstraction is essentially the core of computer science and exceptionally important in everyday programming: learning this sort of mathematics allows you to *unlock* a higher level of abstraction.\n\nSince Category theory is the most abstract branch of math, it's no surprise that it lends itself to great programming abstractions and then to extremely useful programming ideas. Haskell programmers have been tapping this resource for a long time, and the ideas are percolating into other languages.\n\n### Composition\n\nAll software development is composition. \nThe act of breaking a complex problem down to smaller parts, and then composing those smaller solutions together to form structures and patterns, hence your application, well\nthat's what programming is all about.\n\n\u003e We’ve been composing things forever, long before some great engineer came up with the idea of a subroutine. Some time ago the principles of structured programming\n\u003e revolutionized programming because they made blocks of code composable. Then came object oriented programming, which is all about composing objects. Functional programming is\n\u003e not only about composing functions and algebraic data structures — it makes concurrency composable — something that’s virtually impossible with other programming paradigms.\n\u003e -- \u003ccite\u003eBartosz Milewski\u003c/cite\u003e\n\n## Interested in learning more? \n\nI heavely recommend:\n- [Category Theory for Programmers](https://bartoszmilewski.com/2014/10/28/category-theory-for-programmers-the-preface/)\n- [A Pragmatic Introduction to Category Theory—Daniela Sfregola](https://www.youtube.com/watch?v=Ss149MsZluI)\n- [Functors, Applicatives, And Monads In Pictures](https://www.adit.io/posts/2013-04-17-functors,_applicatives,_and_monads_in_pictures.html)\n\nWalking through those resources probably won't change your code overnight. Some people call it\n[general abstract nonsense](https://en.wikipedia.org/wiki/Abstract_nonsense)\nfor a reason. That said, it does provide a nice framework for thinking about\nthese abstract ideas, and is a recommended pursuit for all that are curious.\n\n## Prior Art\n\nThis library draws heavy inspiration from mathematics and other Rust and Elixir libraries: let me mention them here.\n\nThe [`Witchcraft`](https://github.com/witchcrafters/witchcraft) Elixir library is why I started this journey.\n\n[`The Fantasy Land Spec`](https://github.com/fantasyland/fantasy-land) is a spec for\nprojects such as this one, but targeted at Javascript. It does not come with its\nown implementation, but provides a [helpful chart](https://github.com/fantasyland/fantasy-land/raw/master/figures/dependencies.png)\nof class hierarchies.\n\nThe Scala [`Cats`](https://typelevel.org/cats/) library is well documented and exceptionally enlightening on some concepts of category theory.\n\n[`Fp-core.rs`](https://github.com/JasonShin/fp-core.rs) and [`higher`](https://github.com/bodil/higher)\nhave been invaluable resources to help me to port category theory concepts in Rust. \n\nObviously the Haskell [`Prelude`](https://hackage.haskell.org/package/base-4.10.0.0/docs/Prelude.html)\ndeserves mention. Haskell has inspired so many programmers to write clean,\ndeclarative, functional code based on principled abstractions.\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcando%2FAlgar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcando%2FAlgar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcando%2FAlgar/lists"}