# \`Applicative \[\]\` on infinite lists

**URL:** <https://discourse.haskell.org/t/applicative-on-infinite-lists/10236>\
**Category:** Uncategorized\
**Created:** [August 27, 2024, 7:34pm UTC](https://discourse.haskell.org/t/applicative-on-infinite-lists/10236 "2024-08-27T19:34:22Z")\
**Posts on this page:** 4\
**Page:** 2

<div class="post-metadata">

**Author:** ![atravers](https://avatars.discourse-cdn.com/v4/letter/a/45deac/32.png) [@atravers](https://discourse.haskell.org/u/atravers)\
**Post date:** [August 28, 2024, 10:24pm UTC](https://discourse.haskell.org/t/applicative-on-infinite-lists/10236/21 "2024-08-28T22:24:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rhendric](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/rhendric/32/2689_2.png) [@rhendric](https://discourse.haskell.org/u/rhendric)\
**Post date:** [August 28, 2024, 10:29pm UTC](https://discourse.haskell.org/t/applicative-on-infinite-lists/10236/22 "2024-08-28T22:29:11Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![olf](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/olf/32/3813_2.png) [@olf](https://discourse.haskell.org/u/olf)\
**Post date:** [August 29, 2024, 6:08am UTC](https://discourse.haskell.org/t/applicative-on-infinite-lists/10236/23 "2024-08-29T06:08:03Z")

</div>

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

But `(>>)` is literally implemented using a constant function on the right of `(>>=)`, how could the two behave differently? The latest [source](https://hackage.haskell.org/package/ghc-internal-9.1001.0/docs/src/GHC.Internal.Base.html#%3E%3E) 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](https://en.wikibooks.org/wiki/Haskell/Alternative_and_MonadPlus#Alternative_and_MonadPlus_laws) which is even part of the official MonadPlus documentation.

---

<div class="post-metadata">

**Author:** ![rhendric](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/rhendric/32/2689_2.png) [@rhendric](https://discourse.haskell.org/u/rhendric)\
**Post date:** [August 29, 2024, 6:11am UTC](https://discourse.haskell.org/t/applicative-on-infinite-lists/10236/24 "2024-08-29T06:11:51Z")

</div>

> [@olf](#):
>
> The latest [source](https://hackage.haskell.org/package/ghc-internal-9.1001.0/docs/src/GHC.Internal.Base.html#%3E%3E) contains a note that gives a reason why `(>>)` is _not_ an alias for `(*>)`.

That note notwithstanding, in [`Monad []`](https://hackage.haskell.org/package/ghc-internal-9.1001.0/docs/src/GHC.Internal.Base.html#line-1664), 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.

[Previous page](https://discourse.haskell.org/t/applicative-on-infinite-lists/10236.md?page=1)
