gnieh / fs2-data

streaming data parsing and transformation library
https://fs2-data.gnieh.org
Apache License 2.0
152 stars 27 forks source link

Feature request: cell encoder from `cats.Show`? #609

Closed vreuter closed 4 months ago

vreuter commented 4 months ago

Hi, many thanks for an excellent library! I wonder if in the CSV part of this project there'd be interest in adding a small convenience helper -- the capability to build a CellEncoder instance for a type based on the presence of a cats.Show instance for the same type. Maybe just to the CellEncoder companion object, to complement fromToString[A]? So something like:

object CellEncoder:
    ...
    def fromShow[T : Show]: CellEncoder[T] = instance(summon[Show[T]].show)
    ...

Any chance to add this as a helper for building encoders?

ybasket commented 4 months ago

Sounds like a reasonable addition! Want to give it a try and open a PR?

vreuter commented 4 months ago

Yes, I'll give it a shot :)