You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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, andmagnolia
for typeclass derivation.Potential Solution
Enrich
lsug.markup.Decoder
trait with ops usingsimulacrum
. 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
Functor
.What you'll learn
Getting started
Read our Contributor Guide to get set up.
The text was updated successfully, but these errors were encountered: