`Applicative []` on infinite lists

How would this work for (*>) and (>>)?

I suppose repeat () >> [] would start terminating too, despite the fact that repeat () >>= \_ -> [] does not. Would that be so bad?

Or we could change the implementation of (>>) in Monad [] not to be an alias of (*>). I’m honestly fine either way. Using the Monad interface in cases when you could be using Applicative is a signal that you prefer the semantics of Monad over the potential efficiency gains of Applicative, and this is kind of just an extreme case of an efficiency gain.

1 Like

But (>>) is literally implemented using a constant function on the right of (>>=), how could the two behave differently? The latest source contains a note that gives a reason why (>>) is not an alias for (*>).

In favour of also changing the semantics of (>>): Currently the list monad does not obey the right zero law which is even part of the official MonadPlus documentation.

That note notwithstanding, in Monad [], it is.

But as I said, I think there’s an argument for doing it either way and as long as the Applicative instance is well-behaved, I don’t have an opinion on what people who use (>>) get.