So that my code looks similar when using monads to when I use applicatives and functors I have been using =<<
instead of >>=
. I have also been using <*
instead of *>
/ >>
. However I have noticed that <*
is NOT to *>
what =<<
is to >>=
.
For example:
print 5 <* print 6
gives me:
5
6
When I was expecting them to print the other way around, with print 6
being called, printing 6, and then the result ()
getting thrown away and then calling print 5
.
After further playing around it seems like <*
and *>
differ in only the return values, not in things like how the functions are combined / sequenced. Whereas =<<
is a proper flip of >>=
, including a switch in the fixity from left to right.
I was wondering why this was the case (it seems like >>=
is backwards, but it somehow fits better with the, not backwards, <*>
<*
*>
combination, even though the type signatures of >>=
and <*>
are flipped). I was also wondering if there was a <<
style operator I could / should use.
As a side question, when does left vs right associativity even make a difference when it comes to =<<
, it seems as though no matter where you put the parenthesis, the result is the same, although I admittedly only tested with fairly simple examples.