{"id":20601398,"url":"https://github.com/tmccarthy/bfect","last_synced_at":"2025-06-11T13:34:57.730Z","repository":{"id":55035103,"uuid":"186122142","full_name":"tmccarthy/bfect","owner":"tmccarthy","description":"Some bifunctor IO type classes","archived":false,"fork":false,"pushed_at":"2021-01-14T01:05:12.000Z","size":358,"stargazers_count":22,"open_issues_count":3,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-15T01:40:47.310Z","etag":null,"topics":["bifunctor","cats","functional-programming","scala","typeclass","zio"],"latest_commit_sha":null,"homepage":"","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tmccarthy.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":"2019-05-11T11:02:25.000Z","updated_at":"2024-12-09T19:54:14.000Z","dependencies_parsed_at":"2022-08-14T09:40:55.929Z","dependency_job_id":null,"html_url":"https://github.com/tmccarthy/bfect","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmccarthy%2Fbfect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmccarthy%2Fbfect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmccarthy%2Fbfect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmccarthy%2Fbfect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tmccarthy","download_url":"https://codeload.github.com/tmccarthy/bfect/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmccarthy%2Fbfect/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259274290,"owners_count":22832496,"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":["bifunctor","cats","functional-programming","scala","typeclass","zio"],"created_at":"2024-11-16T09:09:54.899Z","updated_at":"2025-06-11T13:34:57.708Z","avatar_url":"https://github.com/tmccarthy.png","language":"Scala","readme":"[![CircleCI](https://circleci.com/gh/tmccarthy/bfect.svg?style=svg)](https://circleci.com/gh/tmccarthy/bfect)\n[![Maven Central](https://img.shields.io/maven-central/v/au.id.tmm.bfect/bfect-core_2.13.svg)](https://repo.maven.apache.org/maven2/au/id/tmm/bfect/bfect-core_2.13/)\n\n# Bfect\n\nA collection of bifunctor effect typeclasses, with instances for ZIO and conversions for cats-effect.\n\n## Project structure\n\n* **`bfect-core`** - A collection of bifunctor effect typeclasses, based loosely around the structure of cats-effect\n* **`bfect-testing`** - An implementation of a bifunctor [state monad](https://typelevel.org/cats/datatypes/state.html) along with instances for the `bfect-core` typeclasses\n* **`bfect-interop-cats`** - Implicit conversions between the `bfect-core` typeclasses and their analogs in `cats-core` and `cats-effect`\n* **`bfect-interop-fs2`** - Utilities for interoperation with [`fs2`](https://github.com/functional-streams-for-scala/fs2/)\n* **`bfect-interop-zio`** - Instances of the `bfect-core` typeclasses for the [ZIO IO monad](https://github.com/zio/zio)\n* **`bfect-io`** - A half-finished bifunctor IO monad (don't use this)\n\nEach of these are available through [Maven Central](https://repo.maven.apache.org/maven2/au/id/tmm/bfect/), just add them to your project with your favourite build tool.\n\n## Typeclasses\n\n![](typeclass-hierarchy.svg)\n\nTypeclass | Cats equivalent | Comment |\n----------|-----------------|---------|\n[`Bifunctor`](core/src/main/scala/au/id/tmm/bfect/Bifunctor.scala) (`BFunctor`) | `cats.Functor`/`cats.Bifunctor` | Functor with `biMap` and its derivations (`map`/`rightMap`, `leftMap`) |\n[`BifunctorMonad`](core/src/main/scala/au/id/tmm/bfect/BifunctorMonad.scala) (`BMonad`) | `cats.Monad` | Monad. Adds `flatMap`, `rightPure` and `leftPure`. |\n[`BifunctorMonadError`](core/src/main/scala/au/id/tmm/bfect/BifunctorMonadError.scala) (`BME`) | `cats.MonadError` | Represents the ability to handle errors with `handleErrorWith`. Comes with the alias `BME`. |\n[`effects.Bracket`](core/src/main/scala/au/id/tmm/bfect/effects/Bracket.scala) | `cats.effect.Bracket` | Bracket. Represents the pure equivalent of `try`/`finally` |\n[`effects.Now`](core/src/main/scala/au/id/tmm/bfect/effects/Now.scala) | `cats.effect.Timer` | Represents the ability to create a timestamp |\n[`effects.Timer`](core/src/main/scala/au/id/tmm/bfect/effects/Timer.scala) | `cats.effect.Timer` | Extends `Now` with the ability to delay execution for a period of time |\n[`effects.Die`](core/src/main/scala/au/id/tmm/bfect/effects/Die.scala) | | Extends `BifunctorMonadError` with the ability to suspend an effect that fails in an unchecked manner |\n[`effects.Sync`](core/src/main/scala/au/id/tmm/bfect/effects/Sync.scala) | `cats.effect.Sync` | Extends `Die` with the ability to suspend arbitrary synchronous effects |\n[`effects.Async`](core/src/main/scala/au/id/tmm/bfect/effects/Async.scala) | `cats.effect.Async` | Extends `Sync` with the ability to register asynchronous effects |\n[`effects.Concurrent`](core/src/main/scala/au/id/tmm/bfect/effects/Concurrent.scala) | `cats.effect.Concurrent` | Represents the effect of starting and cancelling tasks |\n[`effects.extra.Console`](core/src/main/scala/au/id/tmm/bfect/effects/extra/Console.scala) | | Represents the effect of writing to the console |\n[`effects.extra.EnvVars`](core/src/main/scala/au/id/tmm/bfect/effects/extra/EnvVars.scala) | | Represents the effect of accessing environment variables |\n[`effects.extra.Resources`](core/src/main/scala/au/id/tmm/bfect/effects/extra/Resources.scala) | | Represents the effect of accessing Java resources |\n[`effects.extra.Calendar`](core/src/main/scala/au/id/tmm/bfect/effects/extra/Calendar.scala) | | Extends `Now` with the ability to determine the system timezone, enabling computation of the local date and so on. |\n\nNote that unlike in cats, `Bracket` and `Concurrent` are not part of the main inheritance chain that includes `Sync` and `Async`\n\n## Usage\n\nUse the following imports:\n\n* `import au.id.tmm.bfect.syntax.all._` for extension methods\n* `import au.id.tmm.bfect.instances.all._` for instances\n* `import au.id.tmm.bfect.implicits._` for everything\n\n```scala\nimport au.id.tmm.bfect.effects.Sync\nimport au.id.tmm.bfect.implicits._\n\n// Companion objects provide static methods:\n\ndef hello1[F[_, _] : Sync]: F[Nothing, String] = Sync[F].pure(\"hello\")\ndef hello2[F[_, _] : Sync]: F[Nothing, String] = Sync.pure(\"hello\")\n\ndef print1[F[_, _] : Sync](string: String): F[Nothing, Unit] = Sync[F].sync(println(string))\ndef print2[F[_, _] : Sync](string: String): F[Nothing, Unit] = Sync.sync(println(string))\n\n// Sync.Ops provides instance methods. The following are equivalent:\n\ndef printHello1[F[_, _] : Sync]: F[Nothing, Unit] = Sync[F].flatMap(hello1)(print1)\ndef printHello2[F[_, _] : Sync]: F[Nothing, Unit] = hello1.flatMap(print1)\n\n// Importing Sync.Ops enables for-yield syntax:\n\ndef printHello3[F[_, _] : Sync]: F[Nothing, Unit] =\n  for {\n    hello \u003c- hello1\n    _     \u003c- print1(hello)\n  } yield ()\n```\n\n### Cats interoperation\n\nThe `bfect-interop-cats` package provides implicits for interoperation with Cats. This includes instances\nfor effect types using `EitherT`. The easiest way to access these is with the following import:\n\n```scala\nimport au.id.tmm.bfect.interop.cats.implicits._\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftmccarthy%2Fbfect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftmccarthy%2Fbfect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftmccarthy%2Fbfect/lists"}