From b0e83b0afbf8836b97092e16cf2bab79696f8900 Mon Sep 17 00:00:00 2001 From: Adam Hearn <22334119+hearnadam@users.noreply.github.com> Date: Wed, 20 Nov 2024 10:51:22 -0800 Subject: [PATCH] [data] make `Tag[Defer]` compact (#849) --- .../kyo/{ => kernel}/TagCompactTest.scala | 9 ++- .../main/scala/kyo/internal/TagMacro.scala | 71 ++++++++++--------- .../src/main/scala/kyo/kernel/package.scala | 2 +- 3 files changed, 44 insertions(+), 38 deletions(-) rename kyo-core/shared/src/test/scala/kyo/{ => kernel}/TagCompactTest.scala (81%) diff --git a/kyo-core/shared/src/test/scala/kyo/TagCompactTest.scala b/kyo-core/shared/src/test/scala/kyo/kernel/TagCompactTest.scala similarity index 81% rename from kyo-core/shared/src/test/scala/kyo/TagCompactTest.scala rename to kyo-core/shared/src/test/scala/kyo/kernel/TagCompactTest.scala index 86fb2f9db..d2c6ccbae 100644 --- a/kyo-core/shared/src/test/scala/kyo/TagCompactTest.scala +++ b/kyo-core/shared/src/test/scala/kyo/kernel/TagCompactTest.scala @@ -1,6 +1,8 @@ -package kyo +package kyo.kernel -import kyo.kernel.* +import kyo.* +import kyo.kernel.internal.Defer +import org.scalatest.NonImplicitAssertions import org.scalatest.compatible.Assertion class TagCompactTest extends Test: @@ -24,5 +26,8 @@ class TagCompactTest extends Test: "Tag[Emit[Int]]" in { assert(Tag[Emit[Int]].raw == "!Bv;!?s;!=q;!T0;!U1;!V2;[=!Y5;!W3;!U1;!V2;]") } + "Tag[Defer]" in { + assert(Tag[Defer].raw == "!Fz;!?s;!=q;!T0;!U1;!V2;") + } } end TagCompactTest diff --git a/kyo-data/shared/src/main/scala/kyo/internal/TagMacro.scala b/kyo-data/shared/src/main/scala/kyo/internal/TagMacro.scala index 4038232d3..4172c3bbb 100644 --- a/kyo-data/shared/src/main/scala/kyo/internal/TagMacro.scala +++ b/kyo-data/shared/src/main/scala/kyo/internal/TagMacro.scala @@ -133,41 +133,42 @@ object TagMacro: end concat val toCompact = Map( - "java.lang.Object" -> "0", - "scala.Matchable" -> "1", - "scala.Any" -> "2", - "scala.AnyVal" -> "3", - "java.lang.String" -> "4", - "scala.Int" -> "5", - "scala.Long" -> "6", - "scala.Float" -> "7", - "scala.Double" -> "8", - "scala.Boolean" -> "9", - "scala.Unit" -> "a", - "scala.Option" -> "b", - "scala.Some" -> "c", - "scala.None" -> "d", - "scala.Left" -> "e", - "scala.Right" -> "f", - "scala.Tuple2" -> "g", - "scala.collection.immutable.List" -> "h", - "scala.collection.immutable.Nil" -> "i", - "scala.collection.immutable.Map" -> "j", - "scala.Nothing" -> "k", - "java.lang.CharSequence" -> "l", - "java.lang.Comparable" -> "m", - "java.io.Serializable" -> "n", - "scala.Product" -> "o", - "scala.Equals" -> "p", - "kyo.kernel.Effect" -> "q", - "kyo.kernel.ContextEffect" -> "r", - "kyo.kernel.ArrowEffect" -> "s", - "kyo.Abort" -> "t", - "kyo.Async$package$.Async$.Join" -> "u", - "kyo.Emit" -> "v", - "scala.Char" -> "w", - "java.lang.Throwable" -> "x", - "java.lang.Exception" -> "y" + "java.lang.Object" -> "0", + "scala.Matchable" -> "1", + "scala.Any" -> "2", + "scala.AnyVal" -> "3", + "java.lang.String" -> "4", + "scala.Int" -> "5", + "scala.Long" -> "6", + "scala.Float" -> "7", + "scala.Double" -> "8", + "scala.Boolean" -> "9", + "scala.Unit" -> "a", + "scala.Option" -> "b", + "scala.Some" -> "c", + "scala.None" -> "d", + "scala.Left" -> "e", + "scala.Right" -> "f", + "scala.Tuple2" -> "g", + "scala.collection.immutable.List" -> "h", + "scala.collection.immutable.Nil" -> "i", + "scala.collection.immutable.Map" -> "j", + "scala.Nothing" -> "k", + "java.lang.CharSequence" -> "l", + "java.lang.Comparable" -> "m", + "java.io.Serializable" -> "n", + "scala.Product" -> "o", + "scala.Equals" -> "p", + "kyo.kernel.Effect" -> "q", + "kyo.kernel.ContextEffect" -> "r", + "kyo.kernel.ArrowEffect" -> "s", + "kyo.Abort" -> "t", + "kyo.Async$package$.Async$.Join" -> "u", + "kyo.Emit" -> "v", + "scala.Char" -> "w", + "java.lang.Throwable" -> "x", + "java.lang.Exception" -> "y", + "kyo.kernel.package$.internal$.Defer" -> "z" ) val fromCompact = toCompact.map(_.swap).toMap diff --git a/kyo-prelude/shared/src/main/scala/kyo/kernel/package.scala b/kyo-prelude/shared/src/main/scala/kyo/kernel/package.scala index 43f513828..9deaf27eb 100644 --- a/kyo-prelude/shared/src/main/scala/kyo/kernel/package.scala +++ b/kyo-prelude/shared/src/main/scala/kyo/kernel/package.scala @@ -5,7 +5,7 @@ package object kernel: enum Mode derives CanEqual: case Development, Staging, Production - private object internal: + private[kernel] object internal: inline def maxStackDepth = 512 inline def maxTraceFrames = 16