-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Typelevel Twiddles #846
Conversation
Codecov Report
@@ Coverage Diff @@
## main #846 +/- ##
==========================================
- Coverage 85.11% 83.88% -1.24%
==========================================
Files 126 126
Lines 1747 1756 +9
Branches 147 155 +8
==========================================
- Hits 1487 1473 -14
- Misses 260 283 +23
|
Any thoughts on when (if?) we should deprecate legacy twiddle lists (i.e. the left nested tuples). My initial thought was to deprecate them in the 0.6 release and remove them entirely in 1.0. However, parameterized commands make that gradual cutover difficult. Consider: val insertCity2: Command[City] =
sql"""
INSERT INTO city
VALUES ($int4, $varchar, ${bpchar(3)}, $varchar, $int4)
""".command.contramap {
case c => c.id ~ c.name ~ c.code ~ c.district ~ c.pop
} The |
I humbly vote for deprecating them ASAP. The |
One option that I haven't fully thought through is adding an import that opts-in to the 1.0 syntax. For example, without an explicit import, this could would continue to work without change: val insertCity2: Command[City] =
sql"""
INSERT INTO city
VALUES ($int4, $varchar, ${bpchar(3)}, $varchar, $int4)
""".command.contramap {
c => c.id ~ c.name ~ c.code ~ c.district ~ c.pop
} But if you added // On Scala 3 only
val insertCity2: Command[City] =
sql"""
INSERT INTO city
VALUES ($int4, $varchar, ${bpchar(3)}, $varchar, $int4)
""".command.contramap {
c => (c.id, c.name, c.code, c.district, c.pop)
}
// On Scala 2 or Scala2+3 cross build
val insertCity2: Command[City] =
sql"""
INSERT INTO city
VALUES ($int4, $varchar, ${bpchar(3)}, $varchar, $int4)
""".command.contramap {
c => c.id *: c.name *: c.code *: c.district *: c.pop *: EmptyTuple
} |
Never really been a fan of the future opt-in import. I agree with @chuwy that it should just be dealt with ASAP. |
Commands now default to the new twiddle syntax. Adding |
…zed session actions
This PR deprecates left-nested twiddle lists in favor of using Typelevel Twiddles.
Typelevel Twiddles provides a single API that:
As a result, codecs/encoders/decoders are now composed via
*:
instead of~
andgimap
/gmap
/gcontramap
have been replaced withas
.The
~
operation is deprecated and will be removed in Skunk 1.0.Feats of strength were performed to maintain source compatibility. Source breakage was unavoidable in the case of parameterized commands, which now return commands of new style twiddle lists. See the docs page on Twiddle Lists for migration, including the option of adding
import skunk.feature.legacyCommandSyntax
to (temporarily) restore the old behavior.