3 ms·
Validation. You can think of it as shaped like Either [Error] Value, but the implementation is different. Consider this example: pure . Config <$> va
by pdpi 2y ago
Validation. You can think of it as shaped like Either [Error] Value, but the implementation is different. Consider this example:
pure . Config
<$> validate option1
<*> validate option2
<*> validate option3
Either would short circuit on the first validation error. There’s two interesting things here though: there are no data dependencies between different validations (so we don’t _need_ a monad), and it’s useful to accumulate errors to know if both option1 and option3 failed to validate (so we don’t _want_ the Either monad’s short circuiting behaviour). The implementation is pretty straightforward, too!