Skip to content

Rename syntax implicits so they don't clash with other libraries#126

Merged
mpilquist merged 1 commit into
typelevel:mainfrom
Dwolla:ambiguous-implicit-defs
Nov 3, 2025
Merged

Rename syntax implicits so they don't clash with other libraries#126
mpilquist merged 1 commit into
typelevel:mainfrom
Dwolla:ambiguous-implicit-defs

Conversation

@bpholt
Copy link
Copy Markdown
Member

@bpholt bpholt commented Oct 31, 2025

Same as typelevel/cats-mtl#661, but in this library. I'm not sure how the maintainers want the formatting to look; the scalafmt output was ugly so I expanded the // format: off blocks for some of the new code.

The rest of the description is the same as typelevel/cats-mtl#661:


I was trying to use the new custom error types technique with cats-mtl in a Skunk-using project and ran into an unfortunate name collision. AFAICT if you

import cats.mtl.syntax.all._
import skunk._

you end up importing two implicit def toTupleOps methods, one from TwiddleCompat (via Twiddles, via Skunk) and one from TellSyntax via cats-mtl. On Scala 2, they cancel each other out and you end up with errors like

value *: is not a member of skunk.EmptyTuple

Of course, I could do import cats.mtl.syntax.raise._ or even import cats.mtl.syntax.all.{toTupleOps => _, _}, but that's a little unfortunate when teaching the new technique generally. (And users who want to use Tell with Twiddles have to figure out that they need to do something like import cats.mtl.syntax.all.{toTupleOps => catsMtlSyntaxToTupleOps, _}, which is not easily discoverable at all.)

This PR binary-compatibility renames the implicits using the naming pattern established in Cats, which should make it unlikely that these implicit methods will clash with the implicits from other libraries.

@bpholt bpholt marked this pull request as ready for review October 31, 2025 15:50
@mpilquist mpilquist merged commit f2b4ac9 into typelevel:main Nov 3, 2025
11 checks passed
@bpholt bpholt deleted the ambiguous-implicit-defs branch December 3, 2025 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants