I have a question arising from the answer to my question at: haskell Either and Validation Applicative
My code is posted there.
It concerns the use of the *> sequencing operator instead of the <*> applicative operator.
Based on the explanation at https://hackage.haskell.org/package/base-4.15.0.0/docs/Control-Applicative.html#v:-42--62-, I understand that *> sequences actions, discarding the value of the first argument. So for my code, I've tried fail6 = fail2 *> success, which works, but it's not supposed to work because the value of the first argument, namely fail2, should be discarded. Why does fail6 work?
The output of fail6 is Failure [MooglesChewedWires,StackOverflow].
With "discard the result", it means the result of an applicative. So for an
Eitherthat means aRight y.(*>)is thus equivalent to:or in another form:
It thus runs the two actions and returns the second result, but this in the "
Applicativecontext".For example for an
Either, this is implemented as:This thus means that
(*>)is implemented for anEitheras:or equivalent:
If the first operand is thus a
Right …, it will return the second operand, if the first operand isLeft x, it will returnLeft x.