restaumatic/purescript-specular

Export mkWeakDynamic

werner291 opened this issue · 3 comments

I've run into the issue where I'd like to get a WeakDynamic from asyncRequest and asyncRequestMaybe.

It would be useful if I could simply combine one of those two with fromLoaded and mkWeakDynamic to get a WeakDynamic, but mkWeakDynamic isn't exported.

Actually, that's a bad idea because a Dynamic could switch to Nothing. Sorry about the issue.

zyla commented

@werner291 Hello, and thanks for the issue!

  1. You're right that the WeakDynamic invariant would be violated when the request was restarted and state switched to Loading. (One could question whether the invariant is useful at all, but anyway.)
    Nothing in the WeakDynamic was intended to represent "we don't know the value yet", but in a very narrow sense (essentially: so that fixFRP could work despite PureScript being eagerly evaluated).

  2. In our usage of Specular at Restaumatic we actually avoid WeakDynamic and fixFRP (which WeakDynamic was designed for). So I guess it is slated for deprecation/removal. (Of course, if you want to use it in your own code - it's pretty independent of the core primitives, so you could just copy the modules/put them in another package and go.)

fixFrp is what allows us to create circular Event Dynamic propagation, and hence separate our control logic from our view logic. If you're not using fixFrp at Restaumatic, then are you simply mixing the two together within widgets? Is this mixing of concerns simply easier in the long run when attempting to use FRP techniques in an eagerly evaluated language?