Skip to content

Instantly share code, notes, and snippets.

@stephen-lazaro
Created October 4, 2018 19:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephen-lazaro/3785146ff6300571be6871829d709906 to your computer and use it in GitHub Desktop.
Save stephen-lazaro/3785146ff6300571be6871829d709906 to your computer and use it in GitHub Desktop.
// We want to decode _multiple things_ from _one row_
def combine[A, B](left: RowDecoder[A], right: RowDecoder[B]): RowDecoder[(A, B)] = ???
// For example, if we wanted to decode a `Debtor` we want this to work:
final case class Debtor(id: Int, name: String)
// Whip up a decoder using the decoders of the fields!
val debtor: RowDecoder[Debtor] = combine(RowDecoder[Int], RowDecoder[String]).map(Debtor.apply)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment