Skip to content

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

@gwils

Description

@gwils

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions