It would be really useful if the validate and ensure used (a -> Maybe b) instead of (a -> Bool). This would allow the user to output an updated, validated value as a result.
For example, my current use case is that I'm validating an Integer to a Natural, ensuring that the Integer is (n >= 0).
So I could do:
positive :: Integer -> Validation Errors Natural
positive n =
validate (pure $ NegativeVal n) (if n <= then Just $ fromInteger n else Nothing) n
It would be really useful if the
validate
andensure
used(a -> Maybe b)
instead of(a -> Bool)
. This would allow the user to output an updated, validated value as a result.For example, my current use case is that I'm validating an
Integer
to aNatural
, ensuring that theInteger
is(n >= 0)
.So I could do:
What do you think? :)