You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think it reads quite well, and also avoids building a wrong result.
One could also imagine some variants of validate, taking id or const () instead of the constructor
What do you think ?
Another thing I would like to comment is the validateAll function.
I think you're touching on something really interesting with validate; the type (a -> Bool) -> e -> a -> Validation (NonEmpty e) a captures our intuition that the failure condition usually has something to do with -- or is somehow based on -- the input data. While this has been the case every time I've used the package, it's at least conceivable that sometimes it won't be the case. In other words, it seems that validate is less general than failureIf.
For the record, I think this is a good thing! In complex cases, it helps protect you from testing the wrong data. So, I'd be all for adding this combinator to the library. (Also, I like this type better than the validate that takes an (a -> b); feels redundant with the functor instance.)
Hello to both of you,
thanks for your work that helps a lot to understand Haskell concepts.
Not really a bug here, but some comments based on your tutorial, that are hopefully useful.
First, isn't it error prone to do this :
I see a risk of validating a value and building another value. I see
<$
as a smell, and would rather use<$>
.Here, my intuition would be to have a helper
validate
like this :allowing me to write
Or maybe even
then
I think it reads quite well, and also avoids building a wrong result.
One could also imagine some variants of
validate
, takingid
orconst ()
instead of the constructorWhat do you think ?
Another thing I would like to comment is the
validateAll
function.It is defined as
We are throwing the
b
values produced by the validations, and I think the result type is surprising too.I would rather expect, hoping that the validators all returns the same value :
But then, what would
b
be when the foldable is empty ?So if we really want to provide a
validateAll
function, I would rather do :which is only keeping the first produced value, so it might not be so nice.
Maybe
validateAll
is not needed, and*>
would be clearer.Here again, I would be happy to know your point of you.
The text was updated successfully, but these errors were encountered: