These are chat archives for nrinaudo/kantan.csv

23rd
Aug 2017
Andrew Roberts
@aroberts
Aug 23 2017 18:25
am I missing something here?
  implicit val callCsvExportEncoder: RowEncoder[Call] =
    RowEncoder.ordered(call => (
      call.linkedId.toString,
      call.from.userId.map(_.value).getOrElse(""),
      call.from.number_e164.getOrElse(call.from.number),
      call.to.userId.map(_.value).getOrElse(""),
      call.to.number_e164.getOrElse(call.to.number),
      call.direction.toString,
      call.startedAt.format(zonedFormat),
      call.endedAt.format(zonedFormat),
      call.duration.getSeconds.toString,
      call.disposition.toString
    ))
scalac doesn’t like that at all - am I using ordered wrong?
I was expecting the type inference to just work
Andrew Roberts
@aroberts
Aug 23 2017 18:38
hmm - I guess I needed to type the param in the function? (c: Call) => …
Nicolas Rinaudo
@nrinaudo
Aug 23 2017 19:48
@aroberts can I get slightly more context / scalac error?
completely unrelated to your issue, but there's certainly something you're not doing right: you're calling toString everywhere, where you're really supposed to use CellEncoder
for example, call.duration.getSeconds - am I right in assuming this yields a Long or an Int? In which case, the toString is really not necessary
Nicolas Rinaudo
@nrinaudo
Aug 23 2017 19:54
but yes, it does seem like you need to put an explicit type on call. I'm not entirely sure why
Andrew Roberts
@aroberts
Aug 23 2017 19:55
you’re right, I’m in the middle of porting some stuff
I’m headed for cell encoding
but String^9 was the simplest first step
Nicolas Rinaudo
@nrinaudo
Aug 23 2017 19:55
it's probably to do with the fact that ordered is overloaded about 22 times
Andrew Roberts
@aroberts
Aug 23 2017 19:55
yeah
or perhaps that the typer can’t infer the type of the function it expects from the return type?
Nicolas Rinaudo
@nrinaudo
Aug 23 2017 19:56
it really should be able to though...
Andrew Roberts
@aroberts
Aug 23 2017 19:56
i agree...
I don’t have the error in front of me any more, unfortunately
today is one of those 5-tickets-at-the-same-time days
Nicolas Rinaudo
@nrinaudo
Aug 23 2017 19:57
I honestly believe it's to do with the overloading, and with the fact that other libraries prefer having ordered1, ordered2, ...
oh, don't bother, I've reproduced it
scala> case class Foo(i: Int, b: Boolean)
defined class Foo

scala> val fooEncoder: RowEncoder[Foo] = RowEncoder.ordered(f => (f.i, f.b))
<console>:25: error: missing parameter type
       val fooEncoder: RowEncoder[Foo] = RowEncoder.ordered(f => (f.i, f.b))
so - for your problem, use explicit type ascription. Not great, but there you go. And if I can help with the encoding, let me know