Closed antonkulaga closed 7 years ago
This looks very promising. And it looks like it will work with Scala js which I think is very important.
Scalajs is not a problem, the problem is Scala 2.10.4, there there is no blackbox contexts for macroses. I personally do not use 2.10.4 but I see that your lib does.
Regarding ScalaJS: it works ok for me there, but scalajs test adaptor in 0.6.2 contains one bug in test adapter that leads to some memory issues in tests only (like weird Boxed errors in tests)
Yeah, I'm happy to terminate scala 2.10 support if pc is macroized. Old users can still use 1.4.2 and if necessary -- highly unlikely -- I'll backport any bugfixes.
We can create a separate branch to work on this feature.
This is a very worthwhile feature and something I've wanted p-c to do for a long time. Here's more or less how I originally envisaged it would work:
val ccSeq = CaseCollSeq(ann,bob) // It's a wrapper for a Seq[Case class]
scala> ccSeq.names
res0: Seq[String] = ArrayBuffer(Ann, Bob)
This pull req is very close to the desired result. I just think that User.asFrame
is a bit unintuitive for the end user. And I'd like to return a CaseCollSeq from CsvParserFN.parse.
Sadly, I've never written a macro so I'm playing catch up here. Do you think the outlined api is possible?
btw there is a feature branch https://github.com/marklister/product-collections/tree/antonkulaga-NamedFields
Do you think the outlined api is possible?
I do not know how to achieve such api, I am not that good in macroses. I just chose the easiest way - macro annotations and quaziquotes with changing of companion object.
I added creation from case classes. Here how it works
Macro annotations automaticly add
asFrame
method to companion object of a case class. In case of User it will be User.asFrame(someusers:_*) that will return User.Columns class where you can get Columns by case accesors names+"s", in our case: User.names, User.surnames