-
Notifications
You must be signed in to change notification settings - Fork 12
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
Join behaviour #3
Conversation
Finally back from PoPL... I had a look over your patch, but I'm a bit concerned that it's overspecialized to the case ⟦ Beh (Beh (DOM w)) ⇒ Beh (DOM w) ⟧, in particular the code for attachTo which has been duplicated. Really this is an instance of a bigger disease, which is that my code assumes that for any node n of type Beh (DOM w), that n.value == n. You can see this all over the place in the code, e.g. in:
the assumption is that this.downstream1 is a DOMNodesBehaviour, and so has a length field. The invariant that the only nodes of type Beh (DOM w) are instances of DOMNodesBehaviour is broken by the introduction of join, since we can now have nodes of type Beh (DOM w) which are instances of JoinBehaviour instead. There are a couple of possible fixes here: a) Make JoinBehaviour a delegate for every method that a behaviour node might export, or b) Rewrite the rest of the codebase to be more careful about the distinction between nodes of type Beh (DOM w) and DOMNodeBehaviours. I am tempted by (b) since JS doesn't really support delegating, but it does introduce quite a bit of inefficiency, e.g.
|
PS: I should say thanks for your thanks :-) |
Oh yeah strange, some of the existing methods already do delegate to I think option b) sounds good as well (hopefully the inefficiency won't be too terrible, since it's just a constant time hash lookup). I've just started to work on some rudimentary tests for FRP Behaviour stuffs (there are too many combinations of things now to just rely on the demos). Hopefully that will make changes like these a little less worrisome. |
OK, so the invariant we're maintaining is that any node whose Agda type Some tests for FRP behaviours sounds excellent, especially if they can A. On 01/30/2012 06:03 PM, Larry Diehl wrote:
|
Made change and added tests for Behaviour and DOM, let me know what you think. |
I'll try to have a look at this and get back to you tomorrow. On 02/02/2012 07:20 PM, Larry Diehl wrote:
|
OK, this is mostly looking pretty cool. The only thing I'm not sure about is the compareAs method, and its use in the test suite via equalNow. Are compareAs and equalNow just used for testing purposes, or are they needed for something else? |
Yeah, they are just used for testing. My line of thinking was that only exposing equalNow/compareAs in the tests via ≟ seemed like an adequate compromise to get Behaviour/DOM testing achieved (and tackling some kind of equality being exposed in the library another day). |
I think I'd rather do this by making QUnit.agda FRP-aware rather than ok<> : [[ Beh < Bool > ]] -> Test where ok<> b is considered to be passing if at some time it has value There's probably some nasty behaviour with timeouts we'd need to impose A. On 02/03/2012 12:15 PM, Larry Diehl wrote:
|
Hm, yeah having a temporal eventually-like test would also be useful to tests effects from events that eventually happen (though what is currently there suffices for behaviours + dom). I'm not sure if you would be able to keep the logic outside of signal.js though, as how to compare is specialized to the kind of behaviour: |
For the simple tests in FRP.JS.Test.Behaviour we just need a map2 of type: ∀ {A B C} → ⟦ A ⇒ B ⇒ C ⟧ → ⟦ Beh A ⇒ Beh B ⇒ Beh C ⟧ then we can specialize it to: ≟* : ⟦ Beh ⟨ ℕ ⟩ ⇒ Beh ⟨ ℕ ⟩ ⇒ Beh ⟨ Bool ⟩ ⟧ The case of DOM nodes is trickier though. I'd like to avoid exposing DOM DOMNodesBehaviour.prototype.equals which could then be wrapped inside a map2 to give an Agda-level function ≟ : ∀ {w} → ⟦ Beh (DOM w) ⇒ Beh (DOM w) ⇒ Beh ⟨ Bool ⟩ ⟧ This can then be exported as part of the DOM interface, not just in the A. On 02/03/2012 02:20 PM, Larry Diehl wrote:
|
I like the cut of your jib, will try to experiment with this over the weekend. |
Here's a branch with the suggested updates (the commit history would still need to be rebased/rewritten/cleaned):
One thing I still couldn't make my mind up about was where Currently its just in |
Some thoughts... Mainly this is looking pretty good. We should remove attachTo from Map2, and instead be careful about The .equals method is currently giving an equality based on HTML Can we rename ok[t] to ok◇ and put a comment saying that we should add a For withDOW, perhaps the DOW module should export an "unattached" value A. On 02/04/2012 09:51 PM, Larry Diehl wrote:
|
Done.
Good idea, done.
Map2 does not define attachTo, did you mean Join? Right now it's
If possible, I would really like to actually compare rendered Another option I was tempted to do was to define a method that Thanks for the continued detailed feedback, I think this is coming |
Oops, yes I did.
Oh rats, of course you need to attach the node to stop it being GC'd.
Fair enough. I think we're safe, that .equals will just compare the HTML
Best to stick with the built-in DOM-renderer I think, since HTML is such
Indeed, we're pretty close to the magic moment when I can press the |
Cleaned commit history, and shared |
Hooray, change merged. Welcome to the project! |
Nice :) |
Finally got some more time to read over the runtime :)
I had to fix an
insertBefore
argument order bug for this to also work for upstreamDOMNodeBehaviour
's.There were a few other unrelated bugs I spotted, but it's better to turn those fixes into separate commits.
P.S. I think the infrastructure you've built around the agda js backend and this project is very promising, thanks!