These are chat archives for nrinaudo/kantan.csv

Jul 2018
Dermot Haughey
Jul 18 2018 18:45
having trouble how to figure out building a more complex decoder using simpler ones
case class Foo[A](a: A, someOtherValue: Int)
case class Bar(name: String)
def decodeFoo[A : RowDecoder]: RowDecoder[Foo[A]] = { RowDecoder.ordered { (a: A, someOtherValue:Int) => Foo(a, someOtherValue) } }
this doesn't seem to work (somewhat obviously)
Nicolas Rinaudo
Jul 18 2018 23:29
I'm not sure what the point of Bar is in your example, so maybe something's missing in your code?
But in order for this to work, you'd need decodeFoo to be implicit. Also, decodeFoo is a bit of a misnommer. It's not a method that decodes CSV as values of type Foo, but an instance of RowDecoder for type Foo. It's traditionally called fooRowDecoder, althrough that certainly doesn't prevent compilation
@hderms you might also want to consider using the generic module, which lets you derive decoders for Foo and Bar automatically. Check the documentation.