{"id":18584489,"url":"https://github.com/bertrand31/tryt-monad-transformer","last_synced_at":"2025-07-31T06:12:21.074Z","repository":{"id":170071169,"uuid":"209768251","full_name":"Bertrand31/TryT-monad-transformer","owner":"Bertrand31","description":"🎁 A monad transformer to wrap any Try[A] with another Monad and conveniently operate on the nested result","archived":false,"fork":false,"pushed_at":"2020-09-11T15:26:58.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-16T05:37:29.111Z","etag":null,"topics":["cats","functional-programming","monad","scala"],"latest_commit_sha":null,"homepage":"","language":"Scala","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/Bertrand31.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-09-20T10:46:19.000Z","updated_at":"2020-09-11T15:27:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"199330d7-9d52-420c-82ad-4cb43624e170","html_url":"https://github.com/Bertrand31/TryT-monad-transformer","commit_stats":null,"previous_names":["bertrand31/tryt-monad-transformer"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Bertrand31/TryT-monad-transformer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bertrand31%2FTryT-monad-transformer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bertrand31%2FTryT-monad-transformer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bertrand31%2FTryT-monad-transformer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bertrand31%2FTryT-monad-transformer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Bertrand31","download_url":"https://codeload.github.com/Bertrand31/TryT-monad-transformer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bertrand31%2FTryT-monad-transformer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267997183,"owners_count":24178251,"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-07-31T02:00:08.723Z","response_time":66,"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":["cats","functional-programming","monad","scala"],"created_at":"2024-11-07T00:27:41.080Z","updated_at":"2025-07-31T06:12:21.038Z","avatar_url":"https://github.com/Bertrand31.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TryT monad transformer\n\n## Introduction\n\nThis monad transformer is born out of a personal preference for Try over Either for error handling.\n\nBecause the Cats community encourages using Cats' Either for error handling instead of Scala's Try, they provide an EitherT monad transformer, but no TryT.\n\nHowever, I personally prefer using Try for error handling, as it seems to fit the job tighter: it is specific to error handling and can do nothing else.\nIt also makes complete sense that it is \"success-biased\", whereas the fact that Cats' Either is right-biased always seeemed dubious to me. If it's really left or right, there's no reason for it to be biased towards either side.\nWhereas it makes complete sense that Try is success-biased because well, we want our programs to keep running.\n\nBecause of that, I found myself needing an equivalent of EitherT for Try, so I made it myself.\nIt really looks like a hybrid between EitherT and OptionT, with a little less functionnality.\n\nThe things that I've left out are mostly because either they don't apply to Try, or I do not understand them well enough yet.\n\nAll contributions or suggestions are welcome!\n\n## Usage\n\nThere are two ways to wrap a value with the TryT wrapper. Either using the `pure` function on a raw value:\n```scala\nTryT.pure[IO, String](\"foo\")\n// res0: utils.TryT[cats.effect.IO,String] = TryT(IO(Success(foo)))\n```\nOr, the preferred and more useful way, using the standard apply method:\n```scala\nval asyncValue = IO(Try(3))\nTryT(asyncValue)\n// res1: utils.TryT[cats.effect.IO,Int] = TryT(IO$1338210249)\n```\nFrom there, it's easy to operate on the TryT that acts like both monads (here, IO and Try) were fused together:\n```scala\nTryT(IO(Try(3))\n  .map(_ + 3)\n  .subflatMap(number =\u003e Try { number / 6 })\n  .tap(println)\n```\nTo see all the available methods, you can either look at [the source code](https://github.com/Bertrand31/TryT-monad-transformer/blob/master/src/main/scala/tryt/TryT.scala) or [the specs](https://github.com/Bertrand31/TryT-monad-transformer/blob/master/src/test/scala/tryt/TryTSpec.scala).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbertrand31%2Ftryt-monad-transformer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbertrand31%2Ftryt-monad-transformer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbertrand31%2Ftryt-monad-transformer/lists"}