0 | ||| Switching Combinators
1 | |||
2 | ||| Switches allow us to dynamically change the structure
3 | ||| (wiring) of a running network of stream functions.
4 | ||| Semantically, the react on discrete events, but
5 | ||| some of the switching primitives in this module use
6 | ||| the `Either` data type if it allows us to more exactly
7 | ||| describe the semantics of a switch.
17 | --------------------------------------------------------------------------------
18 | -- Immediate Switches
19 | --------------------------------------------------------------------------------
21 | ||| Produces output of the first MSF until it produces
22 | ||| a `Left`, in which case the event will be used to
23 | ||| create a new MSF, which will be immediately evaluated
24 | ||| and used henceforth.
25 | |||
26 | ||| This is a one-time switch, which is often used to
27 | ||| run an MSF a fixed number of times or until a certain
28 | ||| event occurs, after which the replacement will be used.
29 | |||
30 | ||| Note: It is unsafe to use this in a recursive setting,
31 | ||| as it would allow us to create an infinite loop
32 | ||| of streaming functions, all of which return `Left`s
33 | ||| forever. Luckily, the totality checker will prevent us
34 | ||| from doing this.
39 | ||| Produces output of the given MSF until it fires an event,
40 | ||| in which case a new MSF is created,
41 | ||| which will be evaluated immediately and used henceforth.
42 | |||
43 | ||| This uses `switchE` internally, so all restrictions mentioned
44 | ||| there apply.
45 | export
52 | --------------------------------------------------------------------------------
53 | -- Delayed Switches
54 | --------------------------------------------------------------------------------
60 | ||| Produces output of the given MSF until it fires an event,
61 | ||| in which case a new MSF is created,
62 | ||| which will be used in all further evaluation steps.
63 | export
67 | --------------------------------------------------------------------------------
68 | -- Recurring Switches
69 | --------------------------------------------------------------------------------
87 | ||| Produces output of the first MSF until the second
88 | ||| fires an event, in which case a new MSF is created,
89 | ||| which will be used in all futre evaluation cycles.
90 | export