Repository navigation
Import cats.syntax.all instead of cats.implicits in the kernel - #4711
Open
martijnhoekstra wants to merge 1 commit into
Open
martijnhoekstra wants to merge 1 commit into
martijnhoekstra wants to merge 1 commit into
Conversation
Async and GenSpawnInstances imported cats.implicits._, whose initializer builds cats' standard instances. On Scala Native that makes BigDecimal and BigInt reachable from any program that uses Async's default async, which links java.math and imports strtod, strtof, log and log10. The syntax is all these files need; instances come from implicit scope.
Contributor
|
@lolgab , tagging you for interest. |
martijnhoekstra
marked this pull request as ready for review
November 5, 2026 23:08
reardonj
approved these changes
Nov 6, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AsyncandGenSpawnInstancesimportcats.implicits._. Loading that object runs the initializer of all of cats' standard instances, including the ones forBigDecimalandBigInt. On Scala Native the linker then keepsjava.mathand its dependencies in any program that usesAsync's defaultasync/async_/asyncCheckAttempt, including the libc importsstrtod,strtof,logandlog10.This imports
cats.syntax.all._instead; the instances these files use come from implicit scope.GenSpawnInstancesnamedcatsStdInstancesForEitherdirectly, which only the import brought in, so it now asks forAlign[Either[E, *]].Measured on Scala Native 0.5 (Linux x86-64, release-fast, stripped), with a minimal program that calls
Async[F].async_once on a small single-threadedAsyncinstance. The two builds differ only in this import inAsync.scala:cats.implicits._cats.syntax.all._java.mathsymbolscats.instancessymbolsstrtod,strtof,log,log10In a larger freestanding Scala Native program (a TCP echo server on its own effect runtime), the same change took the image from 3,036,296 to 2,484,336 bytes and removed its only references to those four libc functions.
Behaviour is the same.
+kernelJVM/compile,+kernelNative/compileand+lawsJVM/test(1,618 tests on 2.12, 2.13 and 3) pass. The change adds and removes no API, so it could also go toseries/3.7.xif you'd like it in a patch release.