From the docs:
(>>) : Sequentially compose two actions, discarding any value produced by the first
(*>) : Sequence actions, discarding the value of the first argument.
Both seem to me doing the same job.
They are equivalent, in practice.
Historically, Haskell did not have an Applicative
typeclass (hence no *>
), but only a Monad
typeclass (with >>
).
At a certain point, Applicative
was made a superclass of Monad
. At that point, it was introduced *>
as a slightly more general variant of >>
, which does not require one to work with a monad, but merely with an applicative functor.
(*>) :: Applicative f => f a -> f b -> f b
(>>) :: Monad f => f a -> f b -> f b
The net result is that when working with applicatives, we can only use *>
, while when working with monads (which are also applicatives) we can use either *>
or >>
interchangeably, since they are required to be equivalent in that case.
Several other monad-related functions have been similarly generalized to applicatives:
return
is generalized by pure
ap
is generalized by <*>
mapM
is generalized by traverse
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With