nesk / akkurate

The expressive validation library for Kotlin
https://akkurate.dev
Apache License 2.0
225 stars 9 forks source link

Suggestions for examples related to Arrow's integration docs #24

Closed raulraja closed 6 months ago

raulraja commented 6 months ago

This PR updates the Arrow integration documentation, focusing on demonstrating multiple bind operations. The aim is to show how Akkurate handles validations involving more than one operation.

The previous example with a single bind not consuming its result is usually considered an antipattern. In general, binding is only helpful inside an either block if there is more than one value to bind, and the second and further operations are somehow dependent on the results of previous operations.

Here, we assume that for some reason, you should not attempt to validate an author unless you have previously validated a book—still not the best example. The examples can be improved to show an actual use case of dependent monadic operations. Also, the examples may be expanded to include Raise vs. using either blocks and the use of context-receivers.

PoisonedYouth commented 6 months ago

Raise should definitely be added to the examples section.

nesk commented 6 months ago

Thank you @raulraja! 🙏

I took the liberty to alter your examples to fit the styleguide and avoid lines with too much width, but your examples are still there. I've also improved the KDoc for the bind function, based on what you already did in the markdown.