Exporting an event stream

102 views
Skip to first unread message

Zachary Kessin

unread,
Jul 28, 2016, 7:58:58 AM7/28/16
to elm-discuss
I know the idea of having an event stream that can be exported and replayed has been kicked around a bit for a while. Has anyone ever done anything with this? 

Ideally I would like to be able to generate a sequence of events with a QuickCheck type tool (either in elm or erlang)

Zach

--
Zach Kessin
Twitter: @zkessin
Skype: zachkessin

Kasey Speakman

unread,
Aug 16, 2016, 12:35:30 PM8/16/16
to Elm Discuss
I've started looking at this. The first hurdle is that updates return both a model update and a side effect. So you could not replay side effects as they may not be deterministic. (Replay produces Cmd which returns a different result message from first time. The time traveling debugger gets around this by disabling Cmd when replaying.) Not to mention running Cmds depends on some outside access (at least mocking it).

There is a discussion of that here and I made a gist of a possible way to implement side effect isolation here. Look at the comment first to see what it looks like in use.

The other hurdle is events are likely to be union types with data. All the JSON encoding/decoding I've see in Elm for union types are for the simple kind where the case has no other values (like an enum). So having a case with values will be a challenge. In JSON.NET, serialized F# union type `CaseName ("something", 1, 3.5)` would look like this: `{ "Case": "CaseName", "Fields": ["something", 1, 3.5] }`. Note: case values are tuples in F#. Javascript allows arrays to contain dissimilar types, so this works.

But, making a custom encoder/decoder for every union case makes you want to rethink life choices. Indeed, it might be better to just use Redux-style messages where the type is a string so you can send the events out of a port for free. It's a shame to lose out on that nice union syntax, but man the pain.

Even then, you will still feel the pain on decoding. Actually, decoding anything is painfully manual in Elm. However, there are no surprises that way.

Zachary Kessin

unread,
Aug 17, 2016, 12:34:50 AM8/17/16
to elm-discuss
I think the format for exporting types must be someform of json encoding, for everyone's sanity. And I think when you are in "Re play mode" side effects should be ignored in favor of the existing events.

Zach

--
You received this message because you are subscribed to the Google Groups "Elm Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elm-discuss+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Zachary Kessin

unread,
Aug 17, 2016, 12:35:33 AM8/17/16
to elm-discuss
By Side effects I meant commands, sorry still have not had any tea yet today 

Zach

Kasey Speakman

unread,
Aug 17, 2016, 1:37:18 AM8/17/16
to Elm Discuss
I watched a video on the debugger, and it seems possible to ignore the commands with some native javascript modifying Elm's behavior. Seems messy though.
To unsubscribe from this group and stop receiving emails from it, send an email to elm-discuss...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Zach Kessin
Twitter: @zkessin
Skype: zachkessin
Reply all
Reply to author
Forward
0 new messages