-
Notifications
You must be signed in to change notification settings - Fork 0
/
documentation.src.html
567 lines (518 loc) · 27.7 KB
/
documentation.src.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
<div class="row">
<div class="col-md-3">
<div class="sidebar-nav">
<p>
<ul class="nav nav-list">
<li class="nav-header disabled"><a>Try ReactiveML</a></li>
<li><a href="<#ROOTDIR>/tryrml/tryrml.html"> Try it online</a></li>
<li><a href="<#ROOTDIR>/distrib"> Download</a></li>
<li class="nav-header disabled"><a>Compilation</a></li>
<li><a href="#rmlc"> rmlc</a></li>
<li><a href="#rmlbuild"> rmlbuild</a></li>
<li class="nav-header disabled"><a>Process</a></li>
<li><a href="#process"> Process definitions</a></li>
<li><a href="#statements"> Basic statements</a></li>
<li><a href="#compositions"> Compositions</a></li>
<li><a href="#iterators"> Iterators</a></li>
<li class="nav-header disabled"><a>Communication</a></li>
<li><a href="#signalDecl"> Signal declaration</a></li>
<li><a href="#signalEm"> Signal emission</a></li>
<li><a href="#signalSt"> Signal status</a></li>
<li><a href="#signalVal"> Signal value</a></li>
<li class="nav-header disabled"><a>Control</a></li>
<li><a href="#control"> Control structures</a></li>
<li><a href="#config"> Event configurations</a></li>
<li class="nav-header disabled"><a>Library</a></li>
<li><a href="#stdlib"> Standard library</a></li>
</ul>
</p>
</div>
</div><!--/col-md--->
<div class="col-md-9">
<h1>ReactiveML Manual</h1>
<hr>
<p>
<b>ReactiveML</b> is based on
the <a href="http://www-sop.inria.fr/mimosa/rp/generalPresentation/index.html">synchronous
reactive model</a> <!-- of Boussinot --> embedded in an ML language
(here a subset of <a href="http://caml.inria.fr">OCaml</a>). It provides
synchronous parallel composition and dynamic features like the dynamic
creation of processes. In <b>ReactiveML</b>, the reactive model is
integrated at the language level (not as a library) which leads to
safer and more natural programming.
</p>
<p>
This page presents how to <a href="#rmlc">compile a ReactiveML program</a>, the <a href="#summary">syntax and
an intuitive semantics</a> of the language. It terminates with the
documentation of the <a href="#stdlib">standard library</a>. An <a href="<#ROOTDIR>/tryrml">interactive tutorial</a> is also available.
</p>
<section id="rmlc">
<!-- <h3></h3> -->
<h2>Compiling ReactiveML Programs</h2>
<p>
Let <code>hello.rml</code> be a file containing the following program:
</p>
<pre>
<span style="color: #008b8b;">let</span> <span style="color: #008b8b;">process</span> main = print_endline <span style="color: #8b2252;">"Hello World!"</span>
<span style="color: #008b8b;">let</span> () = <span style="color: #008b8b;">run</span> main
</pre>
<p>
To produce an executable, the file must be first compiled into pure
OCaml code using the following command:
</p>
<pre>
rmlc hello.rml
</pre>
<p>
Then, the generated OCaml file (<code>hello.ml</code>) can compiled
and linked with the ReactiveML runtime as follows:
</p>
<pre>
ocamlopt -o hello -I `rmlc -where` unix.cmxa rmllib.cmxa hello.ml
</pre>
<p>
It produces an executable file <code>hello</code> which
displays <code>Hello World!</code>.
</p>
</section>
<section id="rmlbuild">
<h3></h3>
<p>
You can also automate the compilation of ReactiveML programs
using <code>rmlbuild</code>. You can compile the ReactiveML file and
the generated OCaml file in one command:
</p>
<pre>
rmlbuild hello.rml.native
</pre>
<p>
This tool is based on <code>ocamlbuild</code>.
</p>
</section>
<section id="summary">
<h2>Summary of ReactiveML Expressions</h2>
<p>
Terminal symbols are set
in <code>typewriter font</code>.
Non-terminal symbols are set
in <code><i>italic font</i></code>.
Square
brackets <i><code>[]</code></i>
denote optional components. Curly
brackets <i><code>{}</code></i>
denote zero, one or several repetitions of the enclosed
components. Parentheses <i><code>()</code></i>
denote grouping
and <code><i>|</i></code>
denotes alternatives.
</p>
<!-- <div class="row"> -->
<!-- <div class="col-md-6"> -->
<section id="process">
<h3>Process Definitions</h3>
<pre>
<span style="color: #008b8b;">let</span> <span style="color: #008b8b;">process</span> <i><id></i> <i>{</i> <i><pattern></i> <i>}</i> = <i><expr></i> <span style="color: #008b8b;">in</span> <i><expr></i>
<span style="color: #008b8b;">process</span> <i><expr></i>
<span style="color: #008b8b;">proc</span> <i><pattern></i> <i>{</i> <i><pattern></i> <i>}</i> <span style="color: #008b8b;">-></span> <i><expr></i>
</pre>
<p>
Process definitions are introduced by
the <code><span style="color: #008b8b;">process</span></code>
keyword. For instance <code><span style="color: #008b8b;">let</span> <span style="color: #008b8b;">process</span> p x1 x2 ... = e</code>
defines a process <code>p</code> with several
arguments <code>x1</code>, <code>x2</code>, ... and a
body <code>e</code>.
The notation
<code>
<span style="color: #008b8b;">let</span> <span style="color: #008b8b;">process</span> p x1 x2 ... = e</code>
is a shortcut for
<code>
<span style="color: #008b8b;">let</span> p = <span style="color: #008b8b;">fun</span> x1 x2 ... -> <span style="color: #008b8b;">process</span> e</code>
and the notation
<code>
(<span style="color: #008b8b;">proc</span> x1 x2 ... <span style="color: #008b8b;">-></span> e)</code>
is a shortcut for
<code>
(<span style="color: #008b8b;">fun</span> x1 x2 ... <span style="color: #008b8b;">-></span> (<span style="color: #008b8b;">process</span> e))</code>.
</p>
</section>
<hr>
<section id="statements">
<h3>Basic statements</h3>
<pre>
<span style="color: #008b8b;">nothing</span>
<span style="color: #008b8b;">pause</span>
<span style="color: #008b8b;">halt</span>
<span style="color: #008b8b;">run</span> <i><process></i>
</pre>
<p>
<code><span style="color: #008b8b;">nothing</span></code> is equivalent to<code>()</code> (can be used only in a process).<br>
<code><span style="color: #008b8b;">pause</span></code> suspends the
execution until next instant.<br>
<code><span style="color: #008b8b;">halt</span></code>
suspends the execution forever (it is equivalent
to <code><span style="color:
#008b8b;">loop</span> <span style="color:
#008b8b;">pause</span> <span style="color:
#008b8b;">end</span></code>, see below).<br>
<code><span style="color: #008b8b;">run</span> p</code> executes the process <code>p</code>.
</p>
</section>
<hr>
<section id="compositions">
<h3>Compositions</h3>
<pre>
<i><expr></i> ; <i><expr></i>
<i><expr></i> || <i><expr></i>
<span style="color: #008b8b;">let</span> <i><pattern></i> = <i><expr> {</i> <span style="color: #008b8b;">and</span> <i><pattern></i> = <i><expr> }</i> <span style="color: #008b8b;">in</span> <i><expr></i>
<i><expr></i> |> <i><expr></i></pre>
<p>
In ReactiveML, expressions can be composed in
sequence (<code>p;q</code>) or in
parallel (<code>p||q</code>). The expression
<span style="color: #008b8b;">let</span>
x1 = e1 <span style="color: #008b8b;">and</span>
x2 = e2 <span style="color: #008b8b;">and</span>
x3 = e3 <span style="color: #008b8b;">and</span>
... <span style="color: #008b8b;">in</span> e</pre> compute
expressions <code>e1, e2, e3, ...</code> in parallel to use
the result in expresion <code>e</code>.
<br><br> The expression <code>e1 |> e2</code> executes <code>e1</code>
and <code>e2</code> in parallel, but at each
instant <code>e1</code> is executed before <code>e2</code>
(this construct is not supported in all runtime).
</p>
</section>
<hr>
<section id="iterators">
<h3>Iterators</h3>
<pre>
<span style="color: #008b8b;">loop</span> <i><expr></i> <span style="color: #008b8b;">end</span>
<span style="color: #008b8b;">while</span> <i><expr></i> <span style="color: #008b8b;">do</span> <i><expr></i> <span style="color: #008b8b;">done</span>
<span style="color: #008b8b;">for</span> <i><id></i> = <i><expr> (</i> <span style="color: #008b8b;">to</span> <i> | </i> <span style="color: #008b8b;">downto</span> <i>) </i> <span style="color: #008b8b;">do</span> <i><expr></i> <span style="color: #008b8b;">done</span>
<span style="color: #008b8b;">for</span> <i><id></i> = <i><expr> (</i> <span style="color: #008b8b;">to</span> <i> | </i> <span style="color: #008b8b;">downto</span> <i>)</i> <span style="color: #008b8b;">dopar</span> <i><expr></i> <span style="color: #008b8b;">done</span></pre>
<p>
The construct <code><span style="color:
#008b8b;">loop</span>/<span style="color:
#008b8b;">end</span></code> is an infinite
loop. <code><span style="color:
#008b8b;">while</span>/<span style="color:
#008b8b;">do</span>/<span style="color:
#008b8b;">done</span></code> and <code><span style="color:
#008b8b;">for</span>/<span style="color:
#008b8b;">do</span>/<span style="color:
#008b8b;">done</span></code> are the classical loops. They
execute their body several times in sequence. Contrarily,
the <code><span style="color:
#008b8b;">for</span>/<span style="color:
#008b8b;">dopar</span>/<span style="color:
#008b8b;">done</span></code> loop executes its body several
times in parallel.
</p>
</section>
<hr>
<!-- </div> -->
<!-- <div class="col-md-6"> -->
<section id="signalDecl">
<h3>Signal declaration</h3>
<pre>
<span style="color: #008b8b;">signal</span> <i><id> {</i> , <i><id> }</i> <span style="color: #008b8b;">in</span> <i><expr></i>
<span style="color: #008b8b;">signal</span> <i><id></i> <span style="color: #008b8b;">default</span> <i><value></i> <span style="color: #008b8b;">gather</span> <i><function></i> <span style="color: #008b8b;">in</span> <i><expr></i></pre>
<p>
The construct <code><span style="color:
#008b8b;">signal</span> s</code> declares a new signal.
It is also possible to declare several signals at once: <code><span style="color:
#008b8b;">signal</span> s1, s2, s3, ...</code>.
<br>
<br>
Sometimes, multiple values can be emitted on a signal during the same
logical instant. This phenomenon is
called <i>Multi-emission</i>. Hence, when a signal is declared, it is
possible to define how to combine the values emitted during an instant
with the <code>
<span style="color: #008b8b;">signal</span>/<span style="color: #008b8b;">default</span>/<span style="color: #008b8b;">gather</span>
</code> construct. Note that in this case, a default value is required.
<br>
For instance
<code>
<span style="color: #008b8b;">signal</span> s
<span style="color: #008b8b;">default</span> 0
<span style="color: #008b8b;">gather</span>
(<span style="color: #008b8b;">fun</span> x y <span style="color: #008b8b;">-></span> x + y)
</code>
defines a a signal <code>s</code> with <code>0</code> as default
value, and <code>(+)</code> as combination function. Thus, in case of
multi-emission, the value of the signal is the sum of all emitted
values. If no combination function is given, the behavior of the
signal is to collect all emitted values in a list.
</p>
</section>
<hr>
<section id="signalEm">
<h3>Signal emission</h3>
<pre>
<span style="color: #008b8b;">emit</span> <i><signal> [ <value> ]</i></pre>
<p>
Signal emissions are instantaneous broadcasting. Hence, a
signal is present or absent during an instant but it cannot
have both status. The notation <code> <span style="color:
#008b8b;">emit</span> s</code> is a shortcut
for <code> <span style="color: #008b8b;">emit</span> s
()</code>, i.e., emit the value <code>()</code> on
signal <code>s</code>.
</p>
</section>
<hr>
<section id="signalSt">
<h3>Signal status</h3>
<pre>
<span style="color: #008b8b;">present</span> <i><signal></i> <span style="color: #008b8b;">then</span> <i><expr></i> <span style="color: #008b8b;">else</span> <i><expr></i>
<span style="color: #008b8b;">await</span> <i>[</i> <span style="color: #008b8b;">immediate</span> <i>]</i> <i><signal></i>
<span style="color: #008b8b;">pre</span> <i><signal></i></pre>
<p>
The expression <code><span style="color: #008b8b;">present</span>
s <span style="color: #008b8b;">then</span> p <span style="color:
#008b8b;">else</span> q</code> tests the status of a
signal <code>s</code>. If the signal is present,
the <code><span style="color: #008b8b;">then</span></code>
branch <code>p</code> is executed instantaneously, otherwise
the <code><span style="color: #008b8b;">else</span></code>
branch <code>q</code> is executed at the following instant.
<br><br>
The expression <code><span style="color: #008b8b;">await</span> s</code>
waits <code>s</code> to be emitted and terminates at
the following instant. Whereas the expression
<code><span style="color: #008b8b;">await</span> <span style="color:
#008b8b;">immediate</span> s</code> waits <code>s</code> to be
emitted and terminates instantaneously.
<br><br>
Like in Esterel, the non-immediate version
of <code><span style="color: #008b8b;">await</span></code> is the
default one. Hence <code><span style="color: #008b8b;">await</span>
s; <span style="color: #008b8b;">await</span> s</code> waits two
occurrences of <code>s</code>, while
<code><span style="color: #008b8b;">await</span> <span style="color:
#008b8b;">immediate</span> s; <span style="color:
#008b8b;">await</span> <span style="color:
#008b8b;">immediate</span> s</code> is equivalent
to <code><span style="color:
#008b8b;">await</span> <span style="color:
#008b8b;">immediate</span> s</code>.
<br><br>
The expression <code><span style="color: #008b8b;">pre</span> s</code> returns <code>true</code> if the signal
<code>s</code> has been emitted at the preceding, and <code>false</code> otherwise.
</p>
</section>
<hr>
<section id="signalVal">
<h3>Signal value</h3>
<pre>
<span style="color: #008b8b;">await</span> <i><signal> (<pattern>) [</i> <span style="color: #008b8b;">when</span> <i><expr> ]</i> <span style="color: #008b8b;">in</span> <i><expr></i>
<span style="color: #008b8b;">await</span> <i>[</i> <span style="color: #008b8b;">immediate</span> <i>]</i> <span style="color: #008b8b;">one</span> <i><signal> (<variable>)</i> <span style="color: #008b8b;">in</span> <i><expr></i>
<span style="color: #008b8b;">pre</span> ?<i><signal></i>
<span style="color: #008b8b;">last</span> ?<i><signal></i>
<span style="color: #008b8b;">default</span> ?<i><signal></i></pre>
<p>
The construct <code><span style="color:
#008b8b;">await</span> s(v) <span style="color:
#008b8b;">in</span> p</code> waits the emission of a signal <code>s</code>. At
the instant following the emission, the body <code>p</code> is executed in an
environment where the pattern <code>v</code> is bind to the value of the
signal (the combination of the values emitted at the preceding
instant).
<br>
<br>
It is possible to match the value of a signal and keep waiting
if the condition is not satisfied. For instance the
expression <code><span style="color: #008b8b;">await</span>
s(x::y::_) <span style="color: #008b8b;">when</span> (x + y >
42) <span style="color: #008b8b;">in</span> p</code> waits for
a list of at least two elements. Then, the sum of the first two
elements of the list <code>x + y</code> must be greater
than <code>42</code> to trigger the execution
of <code>p</code>.
Notice that this construct keeps waiting when the value of the
signal does not match the pattern (e.g., <code>x::y::_</code>) or if
the condition specified after the when keyword is not
satisfied (e.g., <code>x + y > 42</code>).<br><br>
The expression expression <code><span style="color:
#008b8b;">await</span> <span style="color:
#008b8b;">one</span> s (v) <span style="color:
#008b8b;">in</span> p</code> waits the emission of a
signal <code>s</code> to bind the pattern <code>v</code> with
one of the emitted values on signal <code>s</code>. In case of
multiple emission during an instant, the choice of the value
is not specified. Like <code><span style="color:
#008b8b;">await</span></code>, the body of the expression is
executed at the instant following the reception of the signal
(except if there is the <code><span style="color:
#008b8b;">immediate</span></code> keyword). To be causal by
construction, there is no immediate version of
the <code><span style="color:
#008b8b;">await</span>/<span style="color:
#008b8b;">in</span></code> construct.<br><br>
The expression <code><span style="color: #008b8b;">pre</span> ?s</code> evaluates to the value
associated to <code>s</code> at the preceding instant. If <code>s</code>
has not been emitted at the preceding instant,
<code><span style="color: #008b8b;">pre</span> ?s</code> is equal to the default value given at
the declaration point of the signal. <code><span style="color: #008b8b;">last</span> ?s</code>
has a slight different behavior. It evaluates
to the last value associated to <code>s</code> when it was
emitted. Until the first emission of signal <code>s</code>, <code><span style="color: #008b8b;">pre</span>
?s</code> and <code><span style="color: #008b8b;">last</span> ?s</code> both evaluates to the default
value of <code>s</code>.<br><br>
The expression <code><span style="color: #008b8b;">default</span> s</code> returns the default value
of a signal <code>s</code>.
</p>
</section>
<!-- </div> -->
<hr>
<h3>Control structures</h3>
<section id="control">
<pre>
<span style="color: #008b8b;">do</span> <i><expr></i> <span style="color: #008b8b;">when</span> <i><signal></i> <span style="color: #008b8b;">done</span>
<span style="color: #008b8b;">control</span> <i><expr></i> <span style="color: #008b8b;">with</span> <i><signal> [ (<pattern>) [</i> <span style="color: #008b8b;">when</span> <i> <expr> ] ]</i> <span style="color: #008b8b;">done</span>
<span style="color: #008b8b;">do</span> <i><expr></i> <span style="color: #008b8b;">until</span> <i><signal> [ (<pattern>) [</i> <span style="color: #008b8b;">when</span> <i> <expr> ] [</i> <span style="color: #008b8b;">-></span> <i> <expr> ] ]</i> <span style="color: #008b8b;">done</span>
<span style="color: #008b8b;">do</span> <i><expr></i> <span style="color: #008b8b;">until</span> <i><signal> (<pattern>) [</i> <span style="color: #008b8b;">when</span> <i> <expr> ]</i> <span style="color: #008b8b;">-></span> <i><expr></i>
<i>{</i> | <i><signal> (<pattern>) [</i> <span style="color: #008b8b;">when</span> <i> <expr> ]</i> <span style="color: #008b8b;">-></span> <i><expr></i> <i>}</i> <span style="color: #008b8b;">done</span>
</pre>
<p>
The <code><span style="color:
#008b8b;">do</span>/<span style="color:
#008b8b;">when</span>/<span style="color:
#008b8b;">done</span></code> and <code><span style="color:
#008b8b;">control</span>/<span style="color:
#008b8b;">with</span>/<span style="color:
#008b8b;">done</span></code> constructs allow to suspend the
execution of an expression. <code><span style="color:
#008b8b;">do</span> p <span style="color:
#008b8b;">when</span> s <span style="color:
#008b8b;">done</span></code> executes its body <code>p</code>
only when the signal <code>s</code> is
present. <code><span style="color:
#008b8b;">control</span> p <span style="color:
#008b8b;">with</span> s <span style="color:
#008b8b;">done</span></code> switches between an active mode
and a suspended one each time that the signal <code>s</code>is
present.<br><br>
The preemption construct <code><span style="color:
#008b8b;">do</span> p <span style="color:
#008b8b;">until</span> s <span style="color:
#008b8b;">done</span></code> stops the execution of its
body <code>p</code> at the end of instant when the
signal <code>s</code> is emitted (it is not a looping
construct). It is also posible to define a
handler <code><span style="color: #008b8b;">do</span>
p <span style="color: #008b8b;">until</span>
s <span style="color: #008b8b;">-></span>
q <span style="color: #008b8b;">done</span></code>. In this case, an
emission of signal <code>s</code> stops the execution
of <code>p</code> and launches the execution of <code>q</code>
at the following instant.
<br><br>
Besides, it is always possible to match a given pattern in the
control structure. For instance the
code <code><span style="color: #008b8b;">do</span>
p <span style="color: #008b8b;">until</span> s
(v) <span style="color: #008b8b;">when</span> (v >
0) <span style="color: #008b8b;">-></span>
q <span style="color: #008b8b;">done</span></code> stops the
execution of <code>p</code> and launches <code>q</code> only
if the value emitted on signal <code>s</code> is positive.
</p>
</section>
<hr>
<h3>Event configurations</h3>
<section id="config">
<pre>
<span style="color: #008b8b;">present</span> <i><config></i> <span style="color: #008b8b;">then</span> <i><expr></i> <span style="color: #008b8b;">else</span> <i><expr></i>
<span style="color: #008b8b;">await</span> <i>[</i> <span style="color: #008b8b;">immediate</span> <i>]</i> <i><config></i>
<span style="color: #008b8b;">await</span> <i><config-patt> [</i> <span style="color: #008b8b;">when</span> <i><expr> ]</i> <span style="color: #008b8b;">in</span> <i><expr></i>
<span style="color: #008b8b;">do</span> <i><expr></i> <span style="color: #008b8b;">when</span> <i><config></i> <span style="color: #008b8b;">done</span>
<span style="color: #008b8b;">control</span> <i><expr></i> <span style="color: #008b8b;">with</span> <i><config-patt> [</i> <span style="color: #008b8b;">when</span> <i> <expr> ]</i> <span style="color: #008b8b;">done</span>
<span style="color: #008b8b;">do</span> <i><expr></i> <span style="color: #008b8b;">until</span> <i><config-patt> [</i> <span style="color: #008b8b;">when</span> <i> <expr> ]</i> <span style="color: #008b8b;">-></span> <i><expr></i>
<i>{</i> | <i><config-patt>) [</i> <span style="color: #008b8b;">when</span> <i> <expr> ]</i> <span style="color: #008b8b;">-></span> <i><expr></i> <i>}</i> <span style="color: #008b8b;">done</span>
</pre>
<p>
The behavior of these expressions is the same as before except
that instead of depending on a signal, they depend on a Boolean
configuration of signals. The
expressions <code><i><config></i></code>
and <code><i><config-patt></i></code> are defined as follows:
</p>
<pre>
<i><config></i> ::= <i><signal></i>
| <i><config></i> /\ <i><config></i>
| <i><config></i> \/ <i><config></i>
<i><config-patt></i> ::= <i><signal></i>
| <i><signal></i> (<i><pattern></i>)
| <i><config-patt></i> /\ <i><config-patt></i>
| <i><config-patt></i> \/ <i><config-patt></i>
</pre>
<!-- <table cellspacing=6 cellpadding=0> -->
<!-- <tr> -->
<!-- <td align=right nowrap><code><i><config></i></code></td> -->
<!-- <td align=center nowrap>::=</td> -->
<!-- <td align=left nowrap> <code><i><signal></i><code></td> -->
<!-- </tr> -->
<!-- <tr> -->
<!-- <td align=right nowrap> </td> -->
<!-- <td align=center nowrap>∣</td> -->
<!-- <td align=left nowrap> <code><i><config></i> /\ <i><config></i></td> -->
<!-- </tr> -->
<!-- <tr> -->
<!-- <td align=right nowrap> </td> -->
<!-- <td align=center nowrap>∣</td> -->
<!-- <td align=left nowrap> <code><i><config></i> \/ <i><config></i></td> -->
<!-- </tr> -->
<!-- <tr> -->
<!-- <td align=right nowrap><code><i><config-patt></i></code></td> -->
<!-- <td align=center nowrap>::=</td> -->
<!-- <td align=left nowrap> <code><i><signal></i><code> ∣ <code><i><signal></i>(<i><pattern></i>)<code></td> -->
<!-- </tr> -->
<!-- <tr> -->
<!-- <td align=right nowrap> </td> -->
<!-- <td align=center nowrap>∣</td> -->
<!-- <td align=left nowrap> <code><i><config-patt></i> /\ <i><config-patt></i></td> -->
<!-- </tr> -->
<!-- <tr> -->
<!-- <td align=right nowrap> </td> -->
<!-- <td align=center nowrap>∣</td> -->
<!-- <td align=left nowrap> <code><i><config-patt></i> \/ <i><config-patt></i></td> -->
<!-- </tr> -->
<!-- </table> -->
<p>
For example, the expression <code><span style="color:
#008b8b;">await</span> (s1(x) /\ s2(y)) \/
s3(x::y::_) <span style="color: #008b8b;">when</span> (x + y > 42)
<span style="color: #008b8b;">in</span> e</code> waits for either <code>s1</code> and <code>s2</code>
to be present simultaneously or <code>s3</code> to be present if
its associated value is a list of at least two elements. In
both cases, the variables <code>x</code> and <code>y</code> are
bound and the sum of their value must be greater
than <code>42</code> to trigger the execution of <code>e</code>.
</p>
</section>
</section>
<section id="stdlib">
<h2>Standard Library</h2>
<p>
Any OCaml code can be linked to a ReactiveML program as long as
it provides an interface file (<code>file.rmli</code>) which is compatible with
ReactiveML. Therefore, the standard library of OCaml is
available in ReactiveML.
</p>
<p>
The ReactiveML standard library also provides new modules:
</p>
<ul>
<li><a href="<#ROOTDIR>/documentation/stdlib/Rml_list.html">Module <code>Rml_list</code>: process iterators on lists</a></li>
<li><a href="<#ROOTDIR>/documentation/stdlib/Rml_process_manager.html">Module <code>Rml_process_manager</code>: process management combinators</a></li>
<li><a href="<#ROOTDIR>/documentation/stdlib/Rml_async.html">Module <code>Rml_async</code>: launching asychronous computations.</a></li>
</ul>
<p>
The full list of modules available in the standard library is <a href="<#ROOTDIR>/documentation/stdlib/index.html">here</a>.
</p>
</section>
</div>
</div>