system-f / validation

A data-type like Either but with an accumulating Applicative
Other
99 stars 28 forks source link

Does it make sense to provide isSuccess and isFailure functions? #28

Open dnadales opened 6 years ago

dnadales commented 6 years ago

It'd be nice to have functions

isSuccess, isFailure :: Validate v => v -> Bool

Does this make sense? If so I can submit a PR.

tonymorris commented 6 years ago

You could, but they would be as simple as:

import Control.Lens.Extra(is)
isSuccess = is _Success
isFailure = is _Failure

If you think they are useful, then let's do it! Thanks.

dnadales commented 6 years ago

Oh, I was not aware of the is function. Very nice!

If this information could be included in the documentation I guess we don't need isFailure and isSuccess unless depending on lenses is not an option. But since validation already depends on lens I guess this shouldn't be an issue for the library users.

So I'm in favor of not having these functions :)

Does it make sense to document how _Success and _Failure could be used in combination with is? Or it is expected that any lens-educated person (which excludes me :D ) should know this?