Replies: 3 comments 7 replies
-
@utenma I'm also curious about this - did you invest any time in it? I think it should be possible to simply write a custom pickler for some particular named tuple, however, what would be ideal I guess, would be automatic derivation. I suspect that is a lot harder, particularly if upickle wants to maintain compatibility with earlier scala releases? If a maintainer were to read this and there is an obvious solution sketch, I'd be willing to try and follow the breadcrumbs... |
Beta Was this translation helpful? Give feedback.
-
@lihaoyi Apologies to bother - I've posted a sketch of something that seems to work in a basic sort of way for named tuples above. Is there value in attempting to PR it into the mainline? I assume there are problems, it wouldn't compile with earlier versions of scala 3 for example, so I'm not anticipating this to be super simple. 3.6.1+ I think. I'm not what a good solution to that looks like? Publishing a separate artefact? If you think it has value, I would be willing to give it a go. Otherwise it can exist as a local solution. |
Beta Was this translation helpful? Give feedback.
-
@Quafadas, late answer but got this fragment from scala forum similar to the one posted above inline def pairs[N <: Tuple, V <: Tuple](nt: NamedTuple[N, V]): Unit =
val names = constValueTuple[N]
names.zip(nt.toTuple).toList.foreach(println)
scala> pairs((x = 3, y = 7))
(x,3)
(y,7) |
Beta Was this translation helpful? Give feedback.
-
Ideas on how to map back and forth JSON and scala 3.5 named tuples
Beta Was this translation helpful? Give feedback.
All reactions