{"id":23301859,"url":"https://github.com/briancairl/zen","last_synced_at":"2025-08-22T07:31:54.279Z","repository":{"id":60331633,"uuid":"540281870","full_name":"briancairl/zen","owner":"briancairl","description":"A functional/railway-oriented programming library for C++17","archived":false,"fork":false,"pushed_at":"2022-11-15T16:08:17.000Z","size":525,"stargazers_count":5,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-09T01:08:21.430Z","etag":null,"topics":["cpp","cpp17","cpp20","functional-programming","header-only","multithreading","railway-oriented-programming"],"latest_commit_sha":null,"homepage":"","language":"C++","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/briancairl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-09-23T04:46:03.000Z","updated_at":"2023-10-13T06:29:01.000Z","dependencies_parsed_at":"2023-01-22T03:17:02.569Z","dependency_job_id":null,"html_url":"https://github.com/briancairl/zen","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/briancairl/zen","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/briancairl%2Fzen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/briancairl%2Fzen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/briancairl%2Fzen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/briancairl%2Fzen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/briancairl","download_url":"https://codeload.github.com/briancairl/zen/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/briancairl%2Fzen/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271604821,"owners_count":24788780,"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","status":"online","status_checked_at":"2025-08-22T02:00:08.480Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["cpp","cpp17","cpp20","functional-programming","header-only","multithreading","railway-oriented-programming"],"created_at":"2024-12-20T10:17:41.461Z","updated_at":"2025-08-22T07:31:49.262Z","avatar_url":"https://github.com/briancairl.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Unit Tests](https://github.com/briancairl/zen/actions/workflows/pr.yml/badge.svg)](https://github.com/briancairl/zen/actions/workflows/pr.yml)\n\n# Zen\n\nZen provides facilities for railroad style programming in C++.\n\nThis library supports parallel execution which can be easily swapped into any single-threaded program written with Zen.\n\n## API Documentation\n\nDocumentation for latest version available [here](https://briancairl.github.io/zen/doxygen-out/html/index.html).\n\n## Examples\n\n### Simple sequence\n\n```c++\n#include \u003ciostream\u003e\n\n#include \u003czen/zen.hpp\u003e\n\nint main(int argc, char** argv)\n{\n  using namespace zen;\n\n  auto r = pass(argc, argc)\n         | [](int a, float b) -\u003e result\u003cfloat\u003e { return a + b; }\n         | [](float b) -\u003e result\u003cfloat\u003e { return 2.f * b; };\n\n   if (r.valid())\n   {\n     std::cout \u003c\u003c \"r: \" \u003c\u003c *r \u003c\u003c std::endl;\n   }\n   else\n  {\n    std::cout \u003c\u003c r.status() \u003c\u003c std::endl;\n  }\n};\n```\n\n### Merging with `any` and `all`\n\n```c++\n#include \u003ciostream\u003e\n\n#include \u003czen/zen.hpp\u003e\n\nint main(int argc, char** argv)\n{\n  using namespace zen;\n  auto r = pass(argc, argc)\n         | [](int a, float b) -\u003e result\u003cfloat\u003e\n           {\n             if (a \u003e 2)\n             {\n               // Failure message\n               return \"invalid 1 \"_msg;\n             }\n             return 2 * b;\n           }\n         | any(\n           [](float a) -\u003e result\u003cfloat\u003e { return 2 * a; },\n           [](float a) -\u003e result\u003cfloat\u003e\n           {\n             if (a \u003e 2)\n             {\n               // Failure message\n               return \"invalid 2\"_msg;\n             }\n             return 2 * a;\n           })\n         | all(\n           [](float a) -\u003e result\u003cfloat\u003e { return 2 * a; },\n           [](float a) -\u003e result\u003cfloat\u003e\n           {\n             if (a \u003e 2)\n             {\n               // Failure message\n               return \"invalid 3\"_msg;\n             }\n             return 2 * a;\n           });\n   \n   if (r.valid())\n   {\n     const auto [a, b] = *r;\n     std::cout \u003c\u003c \"a: \" \u003c\u003c a \u003c\u003c std::endl;\n     std::cout \u003c\u003c \"b: \" \u003c\u003c b \u003c\u003c std::endl;\n   }\n   else\n  {\n    std::cout \u003c\u003c r.status() \u003c\u003c std::endl;\n  }\n};\n```\n\n### Easy multi-threading with `any` and `all`\n\n```c++\n#include \u003ciostream\u003e\n\n#include \u003czen/zen.hpp\u003e\n\nint main(int argc, char** argv)\n{\n  using namespace zen;\n\n  exec::thread_pool tp{4};\n\n  auto r = pass(argc, argc)\n         | [](int a, float b) -\u003e result\u003cfloat\u003e { return 2 * b; }\n         | any(\n           tp,\n           [](float a) -\u003e result\u003cfloat\u003e { return 2 * a; },\n           [](float a) -\u003e result\u003cfloat\u003e { return 2 * a; })\n         | all(\n           tp,\n           [](float a) -\u003e result\u003cfloat\u003e { return 2 * a; },\n           [](float a) -\u003e result\u003cfloat\u003e { return 3 * a; },\n           [](float a) -\u003e result\u003cfloat\u003e { return 4 * a; });\n   \n   if (r.valid())\n   {\n     const auto [a, b, c] = *r;\n     std::cout \u003c\u003c \"a: \" \u003c\u003c a \u003c\u003c std::endl;\n     std::cout \u003c\u003c \"b: \" \u003c\u003c b \u003c\u003c std::endl;\n     std::cout \u003c\u003c \"c: \" \u003c\u003c c \u003c\u003c std::endl;\n   }\n   else\n  {\n    std::cout \u003c\u003c r.status() \u003c\u003c std::endl;\n  }\n};\n```\n\n# Running examples\n\n```\nbazel run examples:\u003ctarget\u003e\n```\n\n```\nbazel run examples:zen\n```\n\n# Running tests\n\n## bazel\n\n```\nbazel test test/... --test_output=all --cache_test_results=no --compilation_mode=dbg\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbriancairl%2Fzen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbriancairl%2Fzen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbriancairl%2Fzen/lists"}