{"id":30892317,"url":"https://github.com/funcool/canal","last_synced_at":"2025-12-12T01:35:00.504Z","repository":{"id":29349834,"uuid":"32884026","full_name":"funcool/canal","owner":"funcool","description":"DEPRECATED: A channel monad for cats library","archived":false,"fork":false,"pushed_at":"2015-08-13T05:22:04.000Z","size":207,"stargazers_count":7,"open_issues_count":0,"forks_count":2,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-10-02T02:55:35.089Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/funcool.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}},"created_at":"2015-03-25T18:44:51.000Z","updated_at":"2017-09-04T17:31:36.000Z","dependencies_parsed_at":"2022-07-24T16:17:22.625Z","dependency_job_id":null,"html_url":"https://github.com/funcool/canal","commit_stats":null,"previous_names":["funcool/cats-channel"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/funcool/canal","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funcool%2Fcanal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funcool%2Fcanal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funcool%2Fcanal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funcool%2Fcanal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/funcool","download_url":"https://codeload.github.com/funcool/canal/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funcool%2Fcanal/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27673696,"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-12-11T02:00:11.302Z","response_time":56,"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":[],"created_at":"2025-09-08T19:43:52.666Z","updated_at":"2025-12-12T01:35:00.456Z","avatar_url":"https://github.com/funcool.png","language":"Clojure","readme":"# cats-channels #\n\n**Deprecated**: The new version is now merged into cats library.\n\n[![Clojars Project](http://clojars.org/cats/cats-channel/latest-version.svg)](http://clojars.org/cats/cats-channel)\n\nA channel monad for [cats library](https://github.com/funcool/cats). It works with both, Clojure and\nClojureScript.\n\n## Install ##\n\nThe simplest way to use _cats-channel_ in a Clojure project is by including\nit as a dependency in your *_project.clj_*:\n\n```clojure\n[cats/cats-channel \"0.1.0\"]\n```\n\n## Getting Started ##\n\nIn asynchronous environments with clojure and clojurescript we tend to use core.async, because it\nis a very powerfull abstraction.\n\nIt would be awesome to be able to work with channel as a monadic type, and combine it with error\nmonads for short-circuiting async computations that may fail.\n\nLet's start using channel as a functor:\n\n```clojure\n(require '[cats.core :as m])\n(require '[cats.monad.channel :as channel])\n(require '[cljs.core.async :refer [chan put! \u003c!!]])\n\n;; Declare arbitrary channel with initial value\n(def mychan (channel/with-value 2))\n\n;; Use channel as a functor\n(\u003c!! (m/fmap inc mychan))\n;; =\u003e 3\n```\n\nThe channel type also fulfills the monad abstraction, let see it in action:\n\n```clojure\n(def result (m/mlet [a (channel/with-value 2)\n                     b (channel/with-value 3)]\n              (m/return (+ a b))))\n(\u003c!! result)\n;; =\u003e 5\n```\n\nBut the best of all is coming: combine the channel monad with error monads. It allows to build very\nconcise and simple asynchronous APIs. Let see how you can use it your application:\n\n```clojure\n(require '[cats.monad.either :as either])\n\n;; Declare a monad transformer\n(def either-chan-m\n  (either/either-transformer channel/channel-monad))\n\n;; A success example\n(\u003c!! (m/with-monad either-chan-m\n       (m/mlet [a (channel/with-value (either/right 2))\n                b (channel/with-value (either/right 3))]\n         (m/return (+ a b)))))\n;; =\u003e #\u003cRight [5]\u003e\n```\n\nAs you can see, the code looks very similar to the previos example, with the exception that\nthe value in a channel is not a simple plain value, is an either instance.\n\nLet's see what happens if some computation fails in the mlet composition:\n\n```clojure\n(\u003c!! (m/with-monad either-chan-m\n       (m/mlet [a (channel/with-value (either/left \"Some error\"))\n                b (channel/with-value (either/right 3))]\n         (m/return (+ a b)))))\n;; =\u003e #\u003cLeft [Some error]\u003e\n```\n\nThe result is the expected short-circuiting left, without unexpected nullpointer exceptions\nor similar issues.\n\nWith this compositional power, you can model your asynchronous API with a complete\nerror handling using any error monad (in this case Either).\n\n\n## Faq ##\n\n**Why is not part of cats library directly?**\n\nBecause channel monad depends on core async and we do not want make core.async\nas mandatory dependency.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffuncool%2Fcanal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffuncool%2Fcanal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffuncool%2Fcanal/lists"}