{"id":20230873,"url":"https://github.com/ethul/typeclass-inject","last_synced_at":"2025-08-08T05:07:03.108Z","repository":{"id":9991369,"uuid":"12022465","full_name":"ethul/typeclass-inject","owner":"ethul","description":"Inject has been incorporated into Scalaz","archived":false,"fork":false,"pushed_at":"2013-08-31T14:36:26.000Z","size":128,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-03T20:45:17.601Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/scalaz/scalaz/pull/502","language":"Scala","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/ethul.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":"2013-08-10T15:23:21.000Z","updated_at":"2017-09-08T15:48:11.000Z","dependencies_parsed_at":"2022-08-17T15:10:10.210Z","dependency_job_id":null,"html_url":"https://github.com/ethul/typeclass-inject","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/ethul/typeclass-inject","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethul%2Ftypeclass-inject","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethul%2Ftypeclass-inject/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethul%2Ftypeclass-inject/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethul%2Ftypeclass-inject/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ethul","download_url":"https://codeload.github.com/ethul/typeclass-inject/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethul%2Ftypeclass-inject/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269366853,"owners_count":24405250,"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-08T02:00:09.200Z","response_time":72,"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":"2024-11-14T07:44:07.833Z","updated_at":"2025-08-08T05:07:03.081Z","avatar_url":"https://github.com/ethul.png","language":"Scala","readme":"# Inject\n\nA scala implementation of the `Inject` typeclass from [Data types a la carte](http://www.staff.science.uu.nl/~swier004/Publications/DataTypesALaCarte.pdf) (Swierstra 2008).\n\n# Example\n\n```scala\nimport scalaz.{Coproduct, Free, Functor}, Free.Return\nimport typeclass.Inject, Inject._\n\nsealed trait Test1Algebra[A]\ncase class Test1[A](keys: Seq[String], h: Int =\u003e A) extends Test1Algebra[A]\n\nsealed trait Test1AlgebraInstances {\n  implicit def test1AlgebraAFunctor: Functor[Test1Algebra] =\n    new Functor[Test1Algebra] {\n      def map[A, B](a: Test1Algebra[A])(f: A =\u003e B): Test1Algebra[B] = a match {\n        case Test1(k, h) =\u003e Test1(k, x =\u003e f(h(x)))\n      }\n    }\n}\n\nsealed trait Test1AlgebraFunctions {\n  def test1[F[_] : Functor](keys: Seq[String])(implicit I: Inject[Test1Algebra, F]): Free[F, Int] =\n    inject[F, Test1Algebra, Int](Test1(keys, Return(_)))\n}\n\nobject Test1Algebra extends Test1AlgebraInstances with Test1AlgebraFunctions\n\n\n\nsealed trait Test2Algebra[A]\ncase class Test2[A](keys: Seq[String], h: Int =\u003e A) extends Test2Algebra[A]\n\nsealed trait Test2AlgebraInstances {\n  implicit def test2AlgebraAFunctor: Functor[Test2Algebra] =\n    new Functor[Test2Algebra] {\n      def map[A, B](a: Test2Algebra[A])(f: A =\u003e B): Test2Algebra[B] = a match {\n        case Test2(k, h) =\u003e Test2(k, x =\u003e f(h(x)))\n      }\n    }\n}\n\nsealed trait Test2AlgebraFunctions {\n  def test2[F[_] : Functor](keys: Seq[String])(implicit I: Inject[Test2Algebra, F]): Free[F, Int] =\n    inject[F, Test2Algebra, Int](Test2(keys, Return(_)))\n}\n\nobject Test2Algebra extends Test2AlgebraInstances with Test2AlgebraFunctions\n\n\n\nsealed trait Test3Algebra[A]\ncase class Test3[A](keys: Seq[String], h: Int =\u003e A) extends Test3Algebra[A]\n\nsealed trait Test3AlgebraInstances {\n  implicit def test3AlgebraAFunctor: Functor[Test3Algebra] =\n    new Functor[Test3Algebra] {\n      def map[A, B](a: Test3Algebra[A])(f: A =\u003e B): Test3Algebra[B] = a match {\n        case Test3(k, h) =\u003e Test3(k, x =\u003e f(h(x)))\n      }\n    }\n}\n\nsealed trait Test3AlgebraFunctions {\n  def test3[F[_] : Functor](keys: Seq[String])(implicit I: Inject[Test3Algebra, F]): Free[F, Int] =\n    inject[F, Test3Algebra, Int](Test3(keys, Return(_)))\n}\n\nobject Test3Algebra extends Test3AlgebraInstances with Test3AlgebraFunctions\n\n\n\nobject Test {\n  import Test1Algebra._, Test2Algebra._, Test3Algebra._\n\n  type C0[A] = Coproduct[Test1Algebra, Test2Algebra, A]\n  type C1[A] = Coproduct[Test3Algebra, C0, A]\n  type T[A] = C1[A]\n\n  val res =\n    for {\n      a \u003c- test1[T](\"aa\" :: Nil)\n      b \u003c- test2[T](\"bb\" :: Nil)\n      c \u003c- test3[T](\"cc\" :: Nil)\n    } yield (a, b, c)\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fethul%2Ftypeclass-inject","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fethul%2Ftypeclass-inject","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fethul%2Ftypeclass-inject/lists"}