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

Add a contramap-based encoding example and maybe split up the encoding example more #23

Open
gwils opened this issue Aug 13, 2018 · 0 comments

Comments

@gwils
Copy link
Member

gwils commented Aug 13, 2018

The Encoding.hs file in the example directory shows multiple ways of writing encoders

  • using divided and chosen
  • using contrazip
  • using encodeOf and <>

But it misses a key use-case, which is contramap and <>, since many people are using plain old field accessors instead of lens. It's not explained anywhere that contramap is the function-based version of encodeOf. To make that leap requires knowledge of Contravariant and probably some knowledge of lens to make, so it would be best to have an example.

On the topic of Encoding.hs, it's quite a big example that shows a few different ways to achieve the same thing. Maybe it should be split up into a handful of examples to make it clearer where the separation is and show off the difference in code size between the various examples.

@gwils gwils mentioned this issue Aug 13, 2018
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