{"id":29879443,"url":"https://github.com/typelevel/simulacrum-scalafix","last_synced_at":"2025-07-31T08:46:08.039Z","repository":{"id":37104758,"uuid":"225219400","full_name":"typelevel/simulacrum-scalafix","owner":"typelevel","description":"Simulacrum as Scalafix rules","archived":false,"fork":false,"pushed_at":"2025-07-05T20:28:26.000Z","size":456,"stargazers_count":34,"open_issues_count":11,"forks_count":10,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-07-21T19:37:49.982Z","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":"2019-12-01T19:42:05.000Z","updated_at":"2025-06-30T09:55:34.000Z","dependencies_parsed_at":"2023-10-16T05:09:11.237Z","dependency_job_id":"f1ed24d2-b635-4179-82fc-d04590542c22","html_url":"https://github.com/typelevel/simulacrum-scalafix","commit_stats":{"total_commits":314,"total_committers":10,"mean_commits":31.4,"dds":0.5668789808917197,"last_synced_commit":"61cfba41ce57e8a42a26b16392dd6f63b23a6581"},"previous_names":["travisbrown/simulacrum-scalafix"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/typelevel/simulacrum-scalafix","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typelevel%2Fsimulacrum-scalafix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typelevel%2Fsimulacrum-scalafix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typelevel%2Fsimulacrum-scalafix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typelevel%2Fsimulacrum-scalafix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/typelevel","download_url":"https://codeload.github.com/typelevel/simulacrum-scalafix/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typelevel%2Fsimulacrum-scalafix/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267128402,"owners_count":24040161,"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-26T02:00:08.937Z","response_time":62,"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:05.554Z","updated_at":"2025-07-31T08:46:08.025Z","avatar_url":"https://github.com/typelevel.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simulacrum Scalafix\n\n[![Continuous Integration](https://github.com/typelevel/simulacrum-scalafix/actions/workflows/ci.yml/badge.svg)](https://github.com/typelevel/simulacrum-scalafix/actions/workflows/ci.yml)\n[![Coverage status](https://img.shields.io/codecov/c/github/typelevel/simulacrum-scalafix/master.svg)](https://codecov.io/github/typelevel/simulacrum-scalafix)\n[![Maven Central](https://img.shields.io/maven-central/v/org.typelevel/simulacrum-scalafix-annotations_2.13.svg)](https://maven-badges.herokuapp.com/maven-central/org.typelevel/simulacrum-scalafix-annotations_2.13)\n\nThis project began as an experiment in rewriting Typelevel [Simulacrum][simulacrum] as a set of\n[Scalafix][scalafix] rules. It's currently still a proof-of-concept, but it is able to replace\nSimulacrum 1 in the [Cats][cats] repository without breaking any tests or binary-compatibility checks.\n\nPlease see [this Cats issue](https://github.com/typelevel/cats/issues/3192) for discussion about this experiment.\n\nDevelopment of this tool has been supported by [Permutive][permutive]. Please see our [monthly\nreports][permutive-medium] for updates on the work of the Permutive Community Engineering team.\n\n## Simulacrum rules\n\nSimulacrum 1's `@typeclass` macro annotation adds three kinds of boilerplate, which this project\nfactors into three Scalafix rules:\n\n* `AddSerializable`: This rule adds `extends Serializable` to the root type classes in a type class hierarchy.\n* `AddImplicitNotFound`: This rule adds custom `@implicitNotFound` annotations for type classes.\n* `TypeClassSupport`: This rule adds a summoner method and syntax method support to the type class companion object.\n\n## Dotty compatibility rules\n\nThis repo currently includes a few miscellaneous Scalafix rules that may be useful for experimenting\nwith Dotty cross-compilation:\n\n* `ExpandPolymorphicLambdas`: This rule rewrites kind-projector's polymorphic lambda values to\n  explicit anonymous class instantiations that work on both Scala 2 and Dotty.\n* `ExpandTypeLambdas`: This rule rewrites (a large subset of) [kind-projector][kind-projector]'s\n  type lambda syntax to a representation that currently works on both Scala 2 and Dotty.\n* `ParenthesizeLambdaParamWithType`: This rule parenthesizes lambda parameters with type annotations\n  as needed.\n\nThe first rule [may be used in Cats](https://github.com/typelevel/cats/pull/3193)—it's not yet clear\nwhether the polymorphic SAM support that may eventually be added to Dotty will support\ncross-building there.\n\nThe latter two rules should no longer be necessary in most cases, since Dotty\n[now supports][dotty-kind-projector] a subset of kind-projector's syntax via the `-Ykind-projector`\ncompiler option, and can add parentheses to lambda parameters with type annotations with\n`-language:Scala2Compat -rewrite`.\n\n\n## Building Cats without macro annotations\n\nIt's not currently possible to build Cats with [Dotty][dotty] because Simulacrum 1 uses macro\nannotations, which Dotty doesn't support. The goal of this project is to change that by providing a\nnon-macro-annotation-based version of Simulacrum.\n\nI have a Cats [branch](https://github.com/travisbrown/cats/tree/demo/simulacrum-scalafix) that\ndemonstrates how these Scalafix rules work. You can follow along with the following steps:\n\n1. Add Scalafix and the locally-published Scalafix rules to the Cats build and remove Simulacrum 1, Macro Paradise, etc.\n   This takes [about eight lines](https://github.com/travisbrown/cats/commit/4f6d5c25892e5b07c57b1a8980eb8fc9d0869dae)\n   of configuration.\n2. Add `@noop` annotations to `FlatMap#ifM`, `Functor#ifF`, and `Monad#whileM` and `whileM_`.\n   [This](https://github.com/travisbrown/cats/commit/69d91a0d4ec5987132b936ad6b24351dbd2ee3f8) is necessary for\n   compatibility because Simulacrum 1 didn't handle these methods.\n3. Open an sbt console in the Cats repo and run the following commands:\n   ```\n   sbt:cats\u003e scalafix AddSerializable\n   sbt:cats\u003e scalafix AddImplicitNotFound\n   sbt:cats\u003e scalafix TypeClassSupport\n   sbt:cats\u003e scalafmtAll\n   ```\n   This will result in [some boilerplate](https://github.com/travisbrown/cats/commit/a891d38104bfcc585b22a2c8ed65602fb4e13155) being added to the Cats source files:\n   ```\n   50 files changed, 2461 insertions(+), 17 deletions(-)\n   ```\n4. Run `sbt validateJVM` to verify that tests and binary-compatibility checks pass after the change\n   (and `sbt ++2.13.1 buildJVM` if you want to check Scala 2.13 as well).\n\n## Cross-building cats-core on Dotty\n\nThe instructions below are not up-to-date with Cats master, although they should still work.\nPlease follow [this work-in-progress PR](https://github.com/typelevel/cats/pull/3269) for the\ncurrent status of Dotty cross-building.\n\nYou can add Dotty cross-building with a few additional steps:\n\n1. Add build configuration for Dotty. This is [a net couple dozen lines](https://github.com/travisbrown/cats/commit/53165d502d03e5e8f8555a89aad066ebcb9eb943).\n2. [Move](https://github.com/travisbrown/cats/commit/f304311574ec05d16f4cf8139bffc9e64c833829) the one macro definition in cats-core into a Scala 2-specific source directory tree.\n3. Expand type lambdas and polymorphic function value definitions with the following commands:\n   ```\n   sbt:cats\u003e +scalafix ExpandTypeLambdas\n   sbt:cats\u003e +scalafix ExpandPolymorphicLambdas\n   sbt:cats\u003e +scalafmtAll\n   ```\n   This will result in [a pretty big diff](https://github.com/travisbrown/cats/commit/ef1c4824564a5660e0faa54b8a05e934136d84ac).\n   Unlike the similar Simulacrum boilerplate expansion we did above, this kind-projector expansion\n   probably isn't something we'd ever want to merge—it's just a convenient way to try out Dotty\n   cross-building.\n4. Add [a couple of casts](https://github.com/travisbrown/cats/commit/0ba32c7f873a59f3088d54ac6751e3a0aa0c952a) that Dotty needs for some reason.\n5. Compile on Dotty:\n   ```\n   sbt:cats\u003e ++0.21.0-bin-20191201-65a404f-NIGHTLY\n   sbt:cats\u003e coreJVM/compile\n   sbt:cats\u003e kernelLawsJVM/compile\n   sbt:cats\u003e alleycatsCoreJVM/compile\n   ```\n   These modules should compile without errors (the other laws modules and cats-free will currently fail).\n\n## Community\n\nPeople are expected to follow the [Scala Code of Conduct][code-of-conduct] on GitHub and in any\nother project channels.\n\n## License\n\nThis experimental code is licensed under the **[Apache License, Version 2.0][apache]**\n(the \"License\"); you may not use this software except in compliance with the\nLicense.\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\n[apache]: http://www.apache.org/licenses/LICENSE-2.0\n[cats]: https://github.com/typelevel/cats\n[code-of-conduct]: https://www.scala-lang.org/conduct.html\n[contributing]: https://circe.github.io/circe/contributing.html\n[dotty]: https://dotty.epfl.ch/\n[dotty-kind-projector]: https://github.com/lampepfl/dotty/pull/7775\n[kind-projector]: https://github.com/typelevel/kind-projector\n[permutive]: https://permutive.com/\n[permutive-medium]: https://medium.com/permutive\n[scalafix]: https://github.com/scalacenter/scalafix\n[simulacrum]: https://github.com/typelevel/simulacrum\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftypelevel%2Fsimulacrum-scalafix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftypelevel%2Fsimulacrum-scalafix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftypelevel%2Fsimulacrum-scalafix/lists"}