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

Unify roundtrip and roundtripEffect #2

Merged
merged 1 commit into from Jan 29, 2020

Conversation

1Jajen1
Copy link
Member

@1Jajen1 1Jajen1 commented Jan 27, 2020

I had both methods split previously but that was not necessary.

roundtrip tests an encode and decode function to see if decode . encode == id holds. It also allows for applicative effects in the decode function. This allows the decoder to return e.g. Either/Option/... to indicate failure or other effects while decoding.

roundtripEffect is basically the same thing, but adds the possibility of effects M in the decode and encode functions. This allows to for example define a roundtrip property for writing to and reading from a file.

In the event of failure roundtrip shows the intermediate value (after encoding) and a diff of the initial value and the value produced by decode.

This allows testing encoding and decoding through input and output streams, although I would generally not recommend doing so :)
Copy link
Member

@rachelcarmena rachelcarmena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@rachelcarmena rachelcarmena merged commit 4143efd into master Jan 29, 2020
@rachelcarmena rachelcarmena deleted the unify-roundtrip-variants branch January 29, 2020 09:24
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

Successfully merging this pull request may close these issues.

None yet

2 participants