Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Composition: use one codec after another #26

Closed
sergei-shabanau opened this issue Feb 7, 2019 · 1 comment
Closed

Composition: use one codec after another #26

sergei-shabanau opened this issue Feb 7, 2019 · 1 comment

Comments

@sergei-shabanau
Copy link
Member

I'm trying to understand the use case and how it can be expressed.

We have

case class Codec[I, A](eq: Equiv[I, (I, A)])

which consumes a bit of I to produce A and returns (remainder of I) + A.

We already have product operation to combine two codecs

def ~ [B](that: Codec[I, B]): Codec[I, (A, B)]

which consumes a bit of I to produce A and then consumes a bit of remainder of I to produce B and returns (what is yet remained of I) + (A, B).

I've built (see the difference in that type parameters)

def >> [B](that: Codec[A, B]): Codec[I, (A, B)]

which consumes a bit of I to produce A and then consumes a bit of A to produce B and returns (the remainder of I) + (the remainder of A) + B.

Questions:

  1. Is the use case real?
  2. The signature is confusing, i.e. going from I to (A, B) in both cases, and I believe product is the logical assumption here. Can def >> be expressed differently?
  3. Obviously Codec isn't a monad. Does def >> has anything to do with monadic composition?
@sergei-shabanau
Copy link
Member Author

Superseded by #65

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant