virtual-dom
virtual-dom copied to clipboard
Possible bug with fully qualified types and exporting state
I have a module called TaskRouterTask
, with its corresponding Msg
of UpdateTask (Result String TaskRouterTask)
. TaskRouterTask
is just a simple type alias: type alias TaskRouterTask = { sid : String, name : String }
When trying to export with the time travelling debugger I get the following error:
Cannot use Import or Export
The Main.Msg type of your program cannot be reliably serialized for history files.
Functions cannot be serialized, nor can values that contain functions. This is a problem in these places:
Main.Msg can contain tasks.
The good news is that having values like this in your message type is not so great in the long run. You are better off using simpler data, like union types, in your messages. From there, your update function can pattern match on that data and call whatever functions, JSON decoders, etc. you need. This makes the code much more explicit and easy to follow for other readers (or you in a few months!)
I believe the issue comes from the following part of code:
https://github.com/elm-lang/virtual-dom/blob/2e4f74331d010c7199d803bd9a5c244e1939ef55/src/VirtualDom/Metadata.elm#L124-L133
After discussing the issue on Slack, it was recommend I post this issue.
Platform
- Elm Version: 0.18
- OS: Mac
- Browser: Chrome
- OS & Browser: All latest versions
Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!
Here is what to expect next, and if anyone wants to comment, keep these things in mind.