Lesson 8: Refactoring with Validation
- Adding a dependency
- Nominal refactoring
- 25 minutes
We do a thorough refactoring to switch from
Validation. Despite the fact that those two types are isomorphic to each otherBy “isomorphic to each other” we mean that you could losslessly convert
Validation and vice versa.
Applicative instances are quite different and switching to
Validation allows us to accumulate errors on the left. Since that
Applicative relies on having an instance of
Semigroup to handle the accumulationA semigroup operation is a binary associative operation; in the case of the
String types we’re dealing with, the operation is list concatenation (but without an empty string as an identity value).
, we need to write a
Semigroup instance for our