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

Higher-order signals and equality #11

Open
dbuenzli opened this issue May 10, 2014 · 1 comment
Open

Higher-order signals and equality #11

dbuenzli opened this issue May 10, 2014 · 1 comment

Comments

@dbuenzli
Copy link
Owner

One of the annoyance of working with higher-order signals (i.e. signals carrying signals or events) is that the eq parameter has to be specified explicitly in the combinators that carry these values with ( == ), otherwise update steps will fail now and then with a hard to track down:

 Exception: Invalid_argument "equal: functional value".

We could provide two module Se, Ss that specialize the combinators for signals and events using S.Make. But this is similar to have to write eq:( == ) you need to remember you need to use this alternate set of combinators for such signals and this puts an unwanted burden on the programmer.

I'm not sure something can be done (well implicits, I'm not sure I like the idea of implicits but in that case that would solve it). The problem is that interesting FRP programs are higher-order.

@dbuenzli
Copy link
Owner Author

Possible (bloody) hack:

  1. Add an uid in the first field of emut and smut values, this takes care of distinguishing non equal values.
  2. Catch Invalid_argument on equality testing and return true, as it means 1. will have deemed the values equal.

Problem is that this will affect all possible other 'a values that could be carried by signals, not only signals and events. OTOH these would also raise in such cases. This means that any 'a value that is not able to distinguish itself before hitting a functional value in its structure will be deemed equal by react. We could also do it only when the default ?eq is used.

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

1 participant