reflex-host-examples

BSD-3-CLAUSE License

Stars
18

Reflex Host examples

It is a bit trickier to build an event loop in reflex than in reactive-banana. This is because the facilities provided by reflex are lower-level and more fine-grained.

If you want something higher level you can use, there is refex-host.

If you want to have a look at how to use the various low-level pieces and various things that you can do with them, this is the repository for you.

The canonical example is host.hs, and much of the work here is derived from that.

Host1

The simplest example rigs up an event loop for a pure event network which has an Event as an input and a Behavior as an output.

Host2

The next example rigs up an event loop for a pure event network which has an Event as an input and a Event as an output.

Host3

We now change the example so that we have multiple events for both the inputs and the outputs.

Host4

We add PostBuild here, to give us easy access to an event which fires when our event loop starts.

Host5

We add PerformEvent here, so that we can do IO inside of our event network instead of bolting it on afterwards.

Host6

We split the previous example into an event network that is pure and an event network that is used to take care of the IO.

We then create a function we can use to test the pure part of the event network.