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

Nested Actions wont be executed #119

Closed
NickSeagull opened this issue Sep 7, 2024 · 1 comment
Closed

Nested Actions wont be executed #119

NickSeagull opened this issue Sep 7, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@NickSeagull
Copy link
Contributor

Description

There is a bug in NeoHaskell's action system that prevents actions from being executed when used inside nested modules. This issue arises because of how actions are serialized and then deserialized using Data.Dynamic, which fails to properly match the event types of nested modules.

Details

NeoHaskell adopts a structure similar to the Elm architecture, but instead of calling commands "commands," NeoHaskell refers to them as "actions." For example, to read a file, you use the readText action, which publishes an object into a queue for asynchronous execution by an action worker. Importantly, the submission and execution of actions are entirely decoupled, leading to serialization of the action into an UnknownValue (Data.Dynamic).

Actions in NeoHaskell are polymorphic over a type variable representing the event type, similar to Elm's message type system. The main process is as follows:

  1. Event Registration: At the beginning of the application, action handlers are registered for the main event type of the user application. For example, the readTextHandler is registered for the main event type.

  2. Issue with Nested Modules: When attempting to execute actions within nested modules, actions are not executed because the Data.Dynamic type casting process expects the top-level event type of the user application rather than the nested module's event type. This mismatch causes the action handler to fail, and thus, actions in nested modules are not executed.

Problem Scenario

If a user tries to perform an action, such as reading a file inside a nested module, the action will not execute because the action handler is looking for the top-level event type instead of the nested module's event type.

Proposed Solution

To address this issue, we need to modify NeoHaskell's initialization process to ensure that nested modules are treated as part of the user application. Specifically, we should:

  • Register Nested Module Handlers: Ensure that action handlers are registered for nested modules in addition to the main application module. This will allow nested modules to manage their own event types and ensure their actions are executed properly.
  • Multiple Registrations: By registering handlers for nested modules, actions will be registered multiple times for the appropriate event types, avoiding type mismatches during execution.

Action Items

  1. Update the initialization process to include nested modules as part of the user application.
  2. Ensure that action handlers can be registered multiple times for different event types corresponding to nested modules.
  3. Validate that actions in nested modules execute correctly without type casting errors.
@NickSeagull NickSeagull added the bug Something isn't working label Sep 7, 2024
@NickSeagull NickSeagull self-assigned this Sep 7, 2024
@NickSeagull NickSeagull moved this to In Progress in Roadmap Sep 7, 2024
@NickSeagull
Copy link
Contributor Author

Fixed in #123

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

No branches or pull requests

1 participant