debois/elm-mdl

Functions in Msg objects break import/export in Elm 0.18 debugger

MazeChaZer opened this issue · 3 comments

Cannot use Import or Export

The Update.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:

Material.Dispatch.Config can contain functions and JSON decoders.

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!)

FYI, not using the global mdl state and wiring up all components individually using their Elm architecture functions solves this problem.

@MazeChaZer With the very limited experience I have on Elm and elm-mdl, that sounds like an awful lot of work. Or?
Or, is this something that might be fixed at some stage?

@Spiralis The problem is the general architecture of this libraray, so I don't expect it to be fixed soon.