{"id":29879447,"url":"https://github.com/typelevel/shapeless-3","last_synced_at":"2025-07-31T08:46:14.324Z","repository":{"id":37102167,"uuid":"369893629","full_name":"typelevel/shapeless-3","owner":"typelevel","description":"Generic programming for Scala","archived":false,"fork":false,"pushed_at":"2025-07-06T06:19:08.000Z","size":655,"stargazers_count":197,"open_issues_count":6,"forks_count":24,"subscribers_count":12,"default_branch":"main","last_synced_at":"2025-07-21T18:51:17.590Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/typelevel.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,"zenodo":null}},"created_at":"2021-05-22T19:48:02.000Z","updated_at":"2025-07-16T21:35:26.000Z","dependencies_parsed_at":"2023-10-16T13:18:15.132Z","dependency_job_id":"54c2c630-1453-4f2a-8a96-607883ca73e4","html_url":"https://github.com/typelevel/shapeless-3","commit_stats":{"total_commits":438,"total_committers":24,"mean_commits":18.25,"dds":0.7374429223744292,"last_synced_commit":"02d23e34f30ff568feb01e4aed771b4eaa0d4aeb"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/typelevel/shapeless-3","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typelevel%2Fshapeless-3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typelevel%2Fshapeless-3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typelevel%2Fshapeless-3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typelevel%2Fshapeless-3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/typelevel","download_url":"https://codeload.github.com/typelevel/shapeless-3/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typelevel%2Fshapeless-3/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267899083,"owners_count":24162982,"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-30T02:00:09.044Z","response_time":70,"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-07-31T08:46:06.365Z","updated_at":"2025-07-31T08:46:09.393Z","avatar_url":"https://github.com/typelevel.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# shapeless: generic programming for Scala\n\n[![Discord](https://img.shields.io/discord/632277896739946517.svg?label=\u0026logo=discord\u0026logoColor=ffffff\u0026color=404244\u0026labelColor=6A7EC2)](https://discord.gg/bSQBZA3Ced)\n[![Maven Central](https://img.shields.io/maven-central/v/org.typelevel/shapeless3-deriving_3.svg)](https://maven-badges.herokuapp.com/maven-central/org.typelevel/shapeless3-deriving_3)\n[![Scala.js](https://www.scala-js.org/assets/badges/scalajs-1.5.0.svg)](https://www.scala-js.org)\n\n**shapeless** is a type class and dependent type based generic programming\nlibrary for Scala.\n\n**This repository contains shapeless 3 for Scala 3. For shapeless 2 see its own\n[repository](https://github.com/milessabin/shapeless).**\n\nPlease open issues and PRs for shapeless 2 in the old repository.\n\nshapeless 3 was developed as part of a collaboration with Martin Odersky's\ngroup at EPFL LAMP to develop [language-level support][mirror] for generic\nprogramming for Scala 3. shapeless 3 is included in the [Dotty Community\nBuild][communitybuild].\n\n## Current status\n\nIncluded so far is a full implementation of type class derivation as flexible\nas that of shapeless 2, but generalized across kinds. For derivation of regular\nADTs and type classes compile- and runtime performance are dramatically\nimproved over shapeless 2. This comes with a significantly reduced binary\nfootprint in client code.\n\nSupport is provided for deriving type classes indexed by types of kinds `*`\n(eg.  `Monoid`, `Eq`, `Show`), `* -\u003e *` (eg. `Functor`, `Traverse`, `Monad`)\n`(* -\u003e *) -\u003e *)`, (eg. `FunctorK`, aka `HFunctor` in Haskell) and `* -\u003e * -\u003e *`\n(eg.  `Bifunctor`). Support for additional kinds can be added fairly\nstraightforwardly with a small amount of additional boilerplate for each kind.\n\nThe first two of these kinds equal the power of shapeless 2's `Generic` and\n`Generic1` (see their use in the [Kittens][kittens] type class derivation\nlibrary for [Cats][cats]). The remainder go considerably beyond.\n\nUsing shapeless 3 the derivation of a monoid for a Scala ADT is as simple as,\n\n```scala\nimport shapeless3.deriving.*\n\n// Type class definition, eg. from Cats\ntrait Monoid[A]:\n  def empty: A\n  def combine(x: A, y: A): A\n  extension (x: A) def |+| (y: A): A = combine(x, y)\n\nobject Monoid:\n  given Monoid[Unit] with\n    def empty: Unit = ()\n    def combine(x: Unit, y: Unit): Unit = ()\n\n  given Monoid[Boolean] with\n    def empty: Boolean = false\n    def combine(x: Boolean, y: Boolean): Boolean = x || y\n\n  given Monoid[Int] with\n    def empty: Int = 0\n    def combine(x: Int, y: Int): Int = x+y\n\n  given Monoid[String] with\n    def empty: String = \"\"\n    def combine(x: String, y: String): String = x+y\n\n  given monoidGen[A](using inst: K0.ProductInstances[Monoid, A]): Monoid[A] with\n    def empty: A =\n      inst.construct([t] =\u003e (ma: Monoid[t]) =\u003e ma.empty)\n    def combine(x: A, y: A): A =\n      inst.map2(x, y)([t] =\u003e (mt: Monoid[t], t0: t, t1: t) =\u003e mt.combine(t0, t1))\n\n  inline def derived[A](using gen: K0.ProductGeneric[A]): Monoid[A] = monoidGen\n\n// ADT definition\ncase class ISB(i: Int, s: String, b: Boolean) derives Monoid\nval a = ISB(23, \"foo\", true)\nval b = ISB(13, \"bar\", false)\n\nval c = a |+| b // == ISB(36, \"foobar\", true)\n```\n\nA similar derivation for [`Functor`][functor] allows the following,\n\n```scala\nenum Opt[+A] derives Functor: \n  case Sm[+A](value: A)\n  case Nn\n\nSm(\"foo\").map(_.length) // == Sm(3)\n```\n\nWe can even derive [higher order functors][functork] in almost exactly the same\nway,\n\n```scala\n// An Option like type, with a default\nenum OptionD[T]:\n  case Given(value: T)\n  case Default(value: T)\n\n  def fold: T = this match {\n    case Given(t) =\u003e t\n    case Default(t) =\u003e t\n  }\n\nobject OptionD:\n  val fold: OptionD ~\u003e Id = [t] =\u003e (ot: OptionD[t]) =\u003e ot.fold\n\n// A data type parameterized with an effect\ncase class OrderF[F[_]](\n  item: F[String],\n  quantity: F[Int]\n) derives FunctorK\n\nval incompleteOrder = OrderF(Given(\"Epoisse\"), Default(1))\nval completeOrder = FunctorK[OrderF].mapK(incompleteOrder)(OptionD.fold)\n// == OrderF[Id](\"Epoisse\", 1)\n```\n## Getting started\n\nshapeless 3 is available for Scala 3.0.0 for the JVM and for Scala.js 1.5.0+.\nTo include the deriving module in your project add the following to your build,\n\n```\nlibraryDependencies ++= Seq(\"org.typelevel\" %% \"shapeless3-deriving\" % \"3.4.0\")\n```\n\n## Finding out more about the project\n\nshapeless is part of the [Typelevel][typelevel] family of projects. It is an\nOpen Source project under the Apache License v2, hosted on [GitHub][source].\nBinary artefacts are published to the [Sonatype OSS Repository Hosting\nservice][sonatype] and synced to Maven Central.\n\nMost discussion of shapeless and generic programming in Scala happens on the\nshapeless channel of the [Typelevel Discord][discord].\n\n## Participation\n\nThe shapeless project supports the [Typelevel Code of Conduct][codeofconduct] and\nwants all of its channels (Gitter, github, etc.) to be welcoming environments\nfor everyone.\n\n[codeofconduct]: https://typelevel.org/code-of-conduct.html\n[typelevel]: http://typelevel.org/\n[source]: https://github.com/typelevel/shapeless-3\n[sonatype]: https://oss.sonatype.org/index.html#nexus-search;quick~shapeless\n[gitter]: https://gitter.im/milessabin/shapeless\n[discord]: https://discord.gg/bSQBZA3Ced\n[mirror]: https://dotty.epfl.ch/docs/reference/contextual/derivation.html\n[communitybuild]: https://github.com/lampepfl/dotty/tree/master/community-build/community-projects\n[kittens]: https://github.com/typelevel/kittens\n[cats]: https://github.com/typelevel/cats\n[functor]: https://github.com/typelevel/shapeless-3/blob/505d44658d907c8ce193b6e66a4a9e6396ba0d9a/modules/deriving/src/test/scala/shapeless3/deriving/type-classes.scala#L137-L158\n[functork]:https://github.com/typelevel/shapeless-3/blob/505d44658d907c8ce193b6e66a4a9e6396ba0d9a/modules/deriving/src/test/scala/shapeless3/deriving/type-classes.scala#L290-L308\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftypelevel%2Fshapeless-3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftypelevel%2Fshapeless-3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftypelevel%2Fshapeless-3/lists"}