问题描述:

For the task I'm working on, the signal system of the Elm programming language seems to be an appropriate solution.

But my pure computational functions are implemented in Haskell. Is there a Haskell library that would allow me to construct a signal graph (with my pure functions in the nodes) so that it works like in Elm?

My background

I need to observe intermediate results of a huge computation, on demand, i.e., I don't want to actually format and output each intermediate result, but if it is requested, then I should respond with the most fresh intermediate result (received from the computation signal).

Actually, there are several parallel computations, and some of them use the result of others, so I want several independent output signals for observing them. So I believe I could write an Elm program modeling the system to observe the intermediate results as they are available. (Perhaps, I'm wrong, I should try to write a prototype at least in Elm probably, but I'm also thinking about integrating with my main Haskell code already.)

网友答案:

Helm, which I am currently maintainer of, might be what you are looking for. It does combine the signalling with an SDL window that will always appear. You might be able to hack the render function and still use Helm's Signal without SDL or you could just take inspiration from Helm and write a similar Signal type using Elerea (which Helm uses in the background).

An even better idea might be to modify Helm to allow for use cases where main might not have anything to display and send us a pull-request.

网友答案:

From a comment by Tekmo to the announcement of "Elm 0.15: Tasks, Mailboxes, and import syntax":

The Haskell version of mailboxes is pipes-concurrency. The analog of Elm's Address is an Output and the analog of a Signal is an Input.

(BTW, this seems to be very close to what I was looking for. Initially, in previous versions of Elm, the abstractions I actually wanted seem to have been missing, but tasks and mailboxes might fit my needs quite well. So, and now I know--thanks to the comment by Tekmo--that a similar Haskell library is pipes-concurrency.)

相关阅读:
Top