-
Notifications
You must be signed in to change notification settings - Fork 1
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
Project objectives #11
Comments
Hi @paluh, It's funny you bring up React integration, because I actually want to split that out into its own library so the core event and signal implementation can be used independently. This library started out just as an implementation for signals for reactive UI state modelling, because my main work project needed them. I have looked at Bodil's library before, and didn't want to use it because of the impurity of the implementation in the FFI layer. It's modelled after part of the old Elm runtime, and would not work well with situations where you need the ability to dynamically manage your own subscriptions and transformations/compositions. My original signal implementation was just a few helper functions using So for this library:
The React-specific modules came after examining the implementation of Recoil.js and realising that so much of their complex and messy implementation could be replaced with monadic signals. I'm still not sure of its usefulness though. |
Hi @robertdp,
To be honest I have just quickly noticed the quick differences like react integration so I wasn't sure if there are deeper motives behind this implementation - sorry. It seems that it is good idea to separate react pieces if the core stands on its own. This will clear the picture a bit too I think.
The rest of your response is just wonderful project statement which should go directly into the README I think :-) Anybody then can really appreciate your design choices and understand objectives and become a happy user of this lib! By the way - I'm still trying to understand the details of the monad instances. From a distance I think that I understand that it is "something like ContT" - am I right? ;-) |
Not really like Event: data InputMethod = Controller | MouseAndKeyboard
data InputEvent
= ControllerEvent Controller.Event
| MouseEvent Mouse.Event
| KeyboardEvent Keyboard.Event
switchInputMethod :: Event InputMethod
controllerEvents :: Event Controller.Event
mouseEvents :: Event Mouse.Event
keyboardEvents :: Event Keyboard.Event
inputMethod :: Event InputMethod
inputMethod = switchInputMethod <|> pure MouseAndKeyboard
getInputEvents :: InputMethod -> Event InputEvent
getInputEvents Controller = ControllerEvent <$> controllerEvents
getInputEvents MouseAndKeyboard = (MouseEvent <$> mouseEvents) <|> (KeyboardEvent <$> keyboardEvents)
inputEvents :: Event InputEvents
inputEvents = inputMethod >>= getInputEvents Future events output by An important point is that all state in this example is subscriber-dependent. If Signal: data InputMethod = Controller | MouseAndKeyboard
data InputState
= ControllerState Controller.State
| MouseAndKeyboardState Mouse.State Keyboard.State
inputMethod :: Signal InputMethod
controllerState :: Signal Controller.State
mouseState :: Signal Mouse.State
keyboardState :: Signal Keyboard.State
getInputState :: InputMethod -> Signal InputState
getInputState Controller = ControllerState <$> controllerState
getInputState MouseAndKeyboard = MouseAndKeyboardState <$> mouseState <*> keyboardState
inputState :: Signal InputState
inputState = inputMethod >>= getInputState Signals have a value at all times, so they are continuous as opposed to events which are discreet. Because of this a default input method doesn't need to be provided, and the meaning and semantics of the data flow also changes. Values are also no longer subscriber-dependent, because signals are inherently stateful. Any issues with subscription timing from the event-based example do not apply here. |
@paluh I finally got around to making a README. |
Hi,
This library looks really interesting as it provides ready to use react-basic integration.
Would you be so kind and shortly describe what are the project objectives? Could you please tell me how the event implementation part differs from bodil/purescript-signal for example?
The text was updated successfully, but these errors were encountered: