Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

Refining the Generated Documentation: Part-I

Sumit Rawal answered on May 24, 2023 Popularity 1/10 Helpfulness 1/10

Contents


More Related Answers


Refining the Generated Documentation: Part-I

0

What now?

Outline

Using regular expression from refined type

Generating lenses

What now?

If we take a closer look at our model descriptions, we might see that we could do better in some cases. We can make our ID fields simple strings instead of UUIDs and the language code, which is also defined as a simple string. Let’s get going and clean that up!

Looking at the intermediate model for our API documentation (see the OpenAPI class structure in the tapir library), we realize that modifying such a deeply nested case class structure might result in some really messy code.

We can do better than this. When confronted with big and nested structures, we should pick a tool from our functional programming toolbox which is called optics.

Don’t be scared by the name or all that mathematics; there exist some useful libraries for it. In our case, we will pick Monocle, which provides profunctor optics for Scala. The basic idea of optics is to provide pure functional abstractions for the manipulation of immutable objects. Because of their pure nature, they are composable and that results in code that is more flexible and can more easily be reasoned about. 

Popularity 1/10 Helpfulness 1/10 Language whatever
Source: Grepper
Link to this answer
Share Copy Link
Contributed on May 24 2023
Sumit Rawal
0 Answers  Avg Quality 2/10


X

Continue with Google

By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
X
Grepper Account Login Required

Oops, You will need to install Grepper and log-in to perform this action.