bijection icon indicating copy to clipboard operation
bijection copied to clipboard

Proposal: Add Encoder and Decoder

Open johnynek opened this issue 12 years ago • 6 comments

Something like:

trait Encoder[T, U] {
  def apply(t: T): U
  // and andThen, toFn, 
}

trait Decoder[U, T] {
  def apply(u: U): Try[T]
}

// composition might be clearer than inheritance here.
trait Injection[T, U] {
  def encoder: Encoder[T, U]
  def decoder: Decoder[U, T]
}

trait Bijection[T, U] {
  def encoder: Encoder[T, U]
  def inverseEncoder: Encoder[U, T]
}

johnynek avatar Jan 27 '14 18:01 johnynek

+1

On Monday, January 27, 2014, P. Oscar Boykin [email protected] wrote:

Something like:

trait Encoder[T, U] { def apply(t: T): U // and andThen, toFn, } trait Decoder[U, T] { def apply(u: U): Try[T]} // composition might be clearer than inheritance here.trait Injection[T, U] { def encoder: Encoder[T, U] def decoder: Decoder[U, T]} trait Bijection[T, U] { def encoder: Encoder[T, U] def inverseEncoder: Encoder[U, T]}

— Reply to this email directly or view it on GitHubhttps://github.com/twitter/bijection/issues/158 .

ianoc avatar Jan 27 '14 21:01 ianoc

It all comes back again :)

ianoc mailto:[email protected] January 27, 2014 2:08 PM +1

On Monday, January 27, 2014, P. Oscar Boykin [email protected] wrote:

Something like:

trait Encoder[T, U] { def apply(t: T): U // and andThen, toFn, } trait Decoder[U, T] { def apply(u: U): Try[T]} // composition might be clearer than inheritance here.trait Injection[T, U] { def encoder: Encoder[T, U] def decoder: Decoder[U, T]} trait Bijection[T, U] { def encoder: Encoder[T, U] def inverseEncoder: Encoder[U, T]}

— Reply to this email directly or view it on GitHubhttps://github.com/twitter/bijection/issues/158 .

— Reply to this email directly or view it on GitHub https://github.com/twitter/bijection/issues/158#issuecomment-33422938.

P. Oscar Boykin mailto:[email protected] January 27, 2014 11:25 AM

Something like:

trait Encoder[T, U] { def apply(t: T): U // and andThen, toFn, }

trait Decoder[U, T] { def apply(u: U): Try[T] }

// composition might be clearer than inheritance here. trait Injection[T, U] { def encoder: Encoder[T, U] def decoder: Decoder[U, T] }

trait Bijection[T, U] { def encoder: Encoder[T, U] def inverseEncoder: Encoder[U, T] }

— Reply to this email directly or view it on GitHub https://github.com/twitter/bijection/issues/158.

Sam Ritchie (@sritchie) Paddleguru Co-Founder 703.863.8561 www.paddleguru.com http://www.paddleguru.com/ Twitter http://twitter.com/paddleguru// Facebook http://facebook.com/paddleguru

sritchie avatar Jan 27 '14 21:01 sritchie

@sritchie yep…. twitter.bijection looks like an worse and worse package name. :)

johnynek avatar Jan 28 '14 19:01 johnynek

Tony boy had it right all along!!

sritchie avatar Jan 28 '14 20:01 sritchie

@softprops liked Kodiak

sritchie avatar Jan 28 '14 20:01 sritchie

Thanks @sritchie .I mentioned "Codiak" on the twttrs: think Kodiak the bear but with a C for codec ( for transformations to and fro ). I had a similar idea for a library like bijection a few years back with Codiak as name because I realized there were so many interfaces for client libraries that could be implemented in terms of something like what you guys did actually did a good job of flushing out :) Free free to take this name. I never did anything with that repo as you can probably tell. It may go against twttrs bird rule for names though :). Anyway, feel free to take this name if it make sense.

softprops avatar Jan 28 '14 20:01 softprops