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

Create a typeclass for custom decoding #30

Open
zainab-ali opened this issue Nov 13, 2020 · 0 comments
Open

Create a typeclass for custom decoding #30

zainab-ali opened this issue Nov 13, 2020 · 0 comments
Labels
good first issue Good for newcomers

Comments

@zainab-ali
Copy link
Collaborator

zainab-ali commented Nov 13, 2020

The server contains a decoder trait to decode our custom format into algebraic data types. This can be modelled as a typeclass with instances for each datatype.

We can then make use of several libraries to help construct and use the decoder. simulacrum can be used to generate ops, and magnolia for typeclass derivation.

Potential Solution

Enrich lsug.markup.Decoder trait with ops using simulacrum. This makes working with decoders a little easier.
You can then write the functions required for magnolia to derive instances automatically.
The current decoders are explicit in lsug.markup.Decoders. These can be made implicit and, where possible, rewritten to be derived automatically.

Note that most of the decoders probably won't be able to use generic derivation as they have custom handling for missing tags.

Tests

The assertions in lsug.markup.DecoderAssertions should be rewritten to use an implicit decoder. The existing tests should cover the rewrite, but feel free to add more.

Prerequisites

You should

  • have a basic understanding of functional programming
  • be comfortable using typeclasses on higher-kinded types, for example Functor.
  • be keen on reducing boilerplate

What you'll learn

  • How to create typeclasses with implicits and ops
  • How to use simulacrum to generate typeclass boilerplate
  • How to use magnolia to generate typeclass instances

Getting started

Read our Contributor Guide to get set up.

@zainab-ali zainab-ali added the good first issue Good for newcomers label Nov 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant