How to do a long running calculation in Elm?

Anybody done web workers with Elm before?

It does not look too bad. To do the IPC over ports I need to serialise the starting cube position and any results found with Json encoders. I cannot just pass around the current search state, as it wraps further states as a continuation:

type SearchResult state
    = Complete
    | Goal state (() -> SearchResult state)
    | Ongoing state (() -> SearchResult state)

Instead I would have the worker thread run until it is either stopped by an explicit command, or it reaches the ‘Complete’ state. It would periodically provide updates on its progress as (state, Int, Bool), giving the most recently examined state, a count of how many states have been explored so far, and a flag indicating whether or not the state supplied is a goal state.