{"id":16451719,"url":"https://github.com/tpolecat/typename","last_synced_at":"2025-08-17T11:11:27.459Z","repository":{"id":48369323,"uuid":"314425909","full_name":"tpolecat/typename","owner":"tpolecat","description":"Get the name of a type at compile-time. Amaze your friends!","archived":false,"fork":false,"pushed_at":"2023-03-31T15:14:57.000Z","size":30,"stargazers_count":78,"open_issues_count":2,"forks_count":6,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-07-05T07:07:12.433Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tpolecat.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-11-20T02:33:10.000Z","updated_at":"2025-04-17T12:52:39.000Z","dependencies_parsed_at":"2025-07-05T07:07:15.877Z","dependency_job_id":"911bcd29-0e8d-4a8d-aac3-8e533cc4b405","html_url":"https://github.com/tpolecat/typename","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/tpolecat/typename","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tpolecat%2Ftypename","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tpolecat%2Ftypename/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tpolecat%2Ftypename/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tpolecat%2Ftypename/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tpolecat","download_url":"https://codeload.github.com/tpolecat/typename/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tpolecat%2Ftypename/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270837583,"owners_count":24654391,"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-17T02:00:09.016Z","response_time":129,"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-10-11T10:10:07.284Z","updated_at":"2025-08-17T11:11:27.423Z","avatar_url":"https://github.com/tpolecat.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TypeName\n\nThis is a Scala micro-library that provides:\n\n- a `typeName[A]` method that returns a string representation of `A` for all types in Scala 2, and for most concrete types in Scala 3; and\n- a `TypeName[A]` typeclass for demanding that a type has a name.\n\nThe intent is that you can use this instead of `TypeTag` or other heavy machinery.\n\nTypeName is compiled for Scala **2.12**, **2.13**, and **3.0**.\n\n\n```scala\nlibraryDependencies += \"org.tpolecat\" %% \"typename\" % \u003cversion\u003e\n```\n\n#### Discussion and Demo\n\nThe actual names that are generated depend on your Scala version and what's in scope. They're good for things like error reporting, but don't depend on them being stable through space (i.e., equivalent types may give different names, depending on what's in scope when you ask) or time (names seem to be the same in 2.12 and 2.13, but they're very different in 3.0).\n\nAnyway it's still useful. In Scala 2 the results look a bit like this.\n\n```\nWelcome to Scala 2.13.3 (OpenJDK 64-Bit Server VM, Java 11.0.7).\nType in expressions for evaluation. Or try :help.\n\nscala\u003e import org.tpolecat.typename._\nimport org.tpolecat.typename._\n\nscala\u003e typeName[Map[String, ClassLoader]]\nval res1: String = Map[String,ClassLoader]\n\nscala\u003e def foo[A](a: A)(implicit ev: TypeName[A]) = s\"The type of $a is ${ev.value}\"\ndef foo[A](a: A)(implicit ev: org.tpolecat.typename.TypeName[A]): String\n\nscala\u003e foo(1.23)\nval res2: String = The type of 1.23 is Double\n\nscala\u003e foo(List(Some(1), None, Some(2)))\nval res3: String = The type of List(Some(1), None, Some(2)) is List[Option[Int]]\n```\n\nIn Scala 3 the results are a little different, but still fine.\n\n```\ncala\u003e import org.tpolecat.typename._\n\nscala\u003e typeName[Map[String, ClassLoader]]\nval res0: String = scala.collection.immutable.Map[scala.Predef.String, java.lang.ClassLoader]\n\nscala\u003e def foo[A](a: A)(implicit ev: TypeName[A]) = s\"The type of $a is ${ev.value}\"\ndef foo[A](a: A)(implicit ev: org.tpolecat.typename.TypeName[A]): String\n\nscala\u003e foo(1.23)\nval res1: String = The type of 1.23 is scala.Double\n\nscala\u003e foo(List(Some(1), None, Some(2)))\nval res2: String = The type of List(Some(1), None, Some(2)) is scala.collection.immutable.List[scala.Option[scala.Int]]\n```\n\n#### Known Limitations\n\nIn Scala 2 (this correctly *doesn't* work in Scala 3) you can ask for `typeName[A]` for an unconstrainted type variable `A` and it will happily tell you `\"A\"`, which is almost certainly a bug if you're doing that. You need to introduce `A` like `[A: TypeName]` if you need its name.\n\nIn Scala 3 you sometimes can't get the names of nasty types, for example the type of `List(Vector(1), Set(1))`. I don't know what the limits are.\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftpolecat%2Ftypename","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftpolecat%2Ftypename","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftpolecat%2Ftypename/lists"}