Skip to content
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

Add support for receive function #41

Closed
wende opened this issue Apr 30, 2017 · 6 comments
Closed

Add support for receive function #41

wende opened this issue Apr 30, 2017 · 6 comments

Comments

@wende
Copy link
Owner

wende commented Apr 30, 2017

How to process messages is still up to a debate:

Temporary solution:

Example:

case receive of
  Msg a -> 1

->

receive do
  {:msg, a} -> 1

But since it's impure, unidiomatic, and totally forbids a case of after block it should be discussed and redeveloped after

@OvermindDL1
Copy link

You could always support an after block by mandating it as part of the msg type like:

type Msg
  = Msg String
  | After Int
case receive of
  Msg a -> 1
  After 10 ->

Via the specially named message After or so?

And it is not technically impure, purity in Erlang is per process, and given the same inputs to the same process at the same time in its life cycle it will always generate the same work. ^.^

@wende
Copy link
Owner Author

wende commented May 1, 2017

Wow. This is a very smart and hacky idea. But I definitely like that!

@OvermindDL1
Copy link

Wow. This is a very smart and hacky idea. But I definitely like that!

The Elm syntax does not leave a lot of options open... ^.^;

@wende
Copy link
Owner Author

wende commented Jun 7, 2017

Because of the decisions on how to handle side effects and inherent impurity of receive construct, it won't ever be introduced to Elmchemy, and be possible to use only through special Elmchemy constructs for process message boxes

@wende wende closed this as completed Jun 7, 2017
@OvermindDL1
Copy link

Maybe instead you could emulate it like a 'subscription', when a message is received that matches a pattern then send it on? Unsure of how to 'start' a receive though, hmm... Would be much easier if an Elm 'program' was exactly a GenServer on the Elixir side...

@wende
Copy link
Owner Author

wende commented Jun 13, 2017

After most of Elmchemy's features stabilize and prove themselves in a longer run I will start thinking about redoing Elm runtime in BEAM, so that there are effect modules, and generally pattern for generating side-effects. I just feel like receive is a very controversial feature to put into the project, and I believe it's sacrificing what's the best in Elm
I'm sure we'll find another way to achieve that

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

No branches or pull requests

2 participants