New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ports are not published in the specified order #730

Closed
DavidDTA opened this Issue Oct 13, 2016 · 7 comments

Comments

Projects
None yet
3 participants
@DavidDTA

DavidDTA commented Oct 13, 2016

When using a Cmd.batch to send data over two ports, the ports receive an event in the same order regardless of the order in which they appear in the batch.

Working example:
https://daviddta.github.io/elm-port-order-bug/

Code:
https://github.com/DavidDTA/elm-port-order-bug

Looking at the console, we see that port one always receives the event before port two.

@process-bot

This comment has been minimized.

Show comment
Hide comment
@process-bot

process-bot Oct 13, 2016

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

process-bot commented Oct 13, 2016

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

@DavidDTA

This comment has been minimized.

Show comment
Hide comment
@DavidDTA

DavidDTA Oct 13, 2016

In answer to the robot's questions, I'm using Chrome and Elm 0.17.1.

DavidDTA commented Oct 13, 2016

In answer to the robot's questions, I'm using Chrome and Elm 0.17.1.

@jvoigtlaender

This comment has been minimized.

Show comment
Hide comment
@jvoigtlaender

jvoigtlaender Oct 13, 2016

Contributor

What makes you think this is a bug? Is there any documentation out there that claims any guarantees about the order of stuff happening that is put into Cmd.batch? (Hint: I don't think there is. And there should not be.)

If there is nothing like that to be found, then this is not a bug, but instead some feature you want (order preservation on stuff put into Cmd.batch). In that case, the issue tracker is not the appropriate venue for such a feature request. Such discussions happen on Slack or on the mailing list.

http://elm-lang.org/community

Contributor

jvoigtlaender commented Oct 13, 2016

What makes you think this is a bug? Is there any documentation out there that claims any guarantees about the order of stuff happening that is put into Cmd.batch? (Hint: I don't think there is. And there should not be.)

If there is nothing like that to be found, then this is not a bug, but instead some feature you want (order preservation on stuff put into Cmd.batch). In that case, the issue tracker is not the appropriate venue for such a feature request. Such discussions happen on Slack or on the mailing list.

http://elm-lang.org/community

@DavidDTA

This comment has been minimized.

Show comment
Hide comment
@DavidDTA

DavidDTA Oct 14, 2016

I tried posting to the elm discuss mailing list following your suggesion, but it has not gone through yet (pending approval).

DavidDTA commented Oct 14, 2016

I tried posting to the elm discuss mailing list following your suggesion, but it has not gone through yet (pending approval).

@jvoigtlaender

This comment has been minimized.

Show comment
Hide comment
@jvoigtlaender

jvoigtlaender Oct 14, 2016

Contributor

Okay, I'm sure the message will get through on the mailing list, so am closing the issue here.

Meanwhile, maybe this helps you as well: http://faq.elm-community.org/17.html#what-is-the-difference-between-cmd-and-task

Note that it talks about multiset in relation to Cmd. Multisets have no order.

Contributor

jvoigtlaender commented Oct 14, 2016

Okay, I'm sure the message will get through on the mailing list, so am closing the issue here.

Meanwhile, maybe this helps you as well: http://faq.elm-community.org/17.html#what-is-the-difference-between-cmd-and-task

Note that it talks about multiset in relation to Cmd. Multisets have no order.

@DavidDTA

This comment has been minimized.

Show comment
Hide comment
@DavidDTA

DavidDTA Oct 14, 2016

A few questions about the linked article:

  1. The article claims that Cmd is not monadic, but I believe that the existence of Cmd.Extra.message and Cmd.map indicates that it is.
  2. The article mentions that APIs generally expose Task in favor of Cmd. Why is the port API a -> Cmd msg instead of a -> Task Never () or something like that?
  3. Is there a recommended way to pass data to ports in order? I've come up with the workaround of sending over only one port per update and using Cmd.Extra.message to trigger additional updates immediately, but I don't think it's very clean.

DavidDTA commented Oct 14, 2016

A few questions about the linked article:

  1. The article claims that Cmd is not monadic, but I believe that the existence of Cmd.Extra.message and Cmd.map indicates that it is.
  2. The article mentions that APIs generally expose Task in favor of Cmd. Why is the port API a -> Cmd msg instead of a -> Task Never () or something like that?
  3. Is there a recommended way to pass data to ports in order? I've come up with the workaround of sending over only one port per update and using Cmd.Extra.message to trigger additional updates immediately, but I don't think it's very clean.
@jvoigtlaender

This comment has been minimized.

Show comment
Hide comment
@jvoigtlaender

jvoigtlaender Oct 14, 2016

Contributor

All these are good questions. For the mailing list.

But let me answer the first one quickly: For something to be monadic, you need not just (in Haskell terms) "something like return" and "something like fmap", which is what Cmd.Extra.message and Cmd.map are. You also need "something like >>=". And that's exactly what Cmd does not have. Thus it is not monadic. Maybe your understanding of "monadic" is wrong/incomplete.

Contributor

jvoigtlaender commented Oct 14, 2016

All these are good questions. For the mailing list.

But let me answer the first one quickly: For something to be monadic, you need not just (in Haskell terms) "something like return" and "something like fmap", which is what Cmd.Extra.message and Cmd.map are. You also need "something like >>=". And that's exactly what Cmd does not have. Thus it is not monadic. Maybe your understanding of "monadic" is wrong/incomplete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment