-
Notifications
You must be signed in to change notification settings - Fork 3
/
fmlib_browser.mli
1463 lines (910 loc) · 34.7 KB
/
fmlib_browser.mli
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
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
(** Web Applications Running in the Browser
This library helps to write web applications which run in the browser. See
some simple
{{: https://hbr.github.io/fmlib/webapp/index.html} live examples} and look
into the
{{: https://github.com/hbr/fmlib/tree/master/src/examples/browser/webapp.ml}
source code}.
For a step by step introduction see
{{!page-doc} "Introduction to Web Applications"}.
*)
(** {1 Utilities} *)
(** Generate Random Numbers *)
module Random:
sig
type 'a t
(** Generator, generating random values of type ['a]. *)
val constant: 'a -> 'a t
(** [constant a] Generate the same value every time. *)
val (>>=): 'a t -> ('a -> 'b t) -> 'b t
(** [rand >>= f] Generate the random value [a] using the generator [rand],
and then use [f a] to generate a random value [b].
*)
val ( let* ): 'a t -> ('a -> 'b t) -> 'b t
(** [let* a = rand in f a] is the same as [rand >>= f]. *)
val map: ('a -> 'b) -> 'a t -> 'b t
(** [map f rand] Use [rand] to generate a random value and then map it by
[f]. *)
val int: int -> int t
(** [int bound] A random generator which generates numbers [n] satisfying
[0 <= n < bound].
Precondition: [0 < bound]
*)
val float: float -> float t
(** [float bound] A random generator which generates numbers [n] satisfying
[0.0 <= n <= bound].
Precondition: [0 <= bound]
*)
val bool: bool t
(** Generate a random boolean value. *)
val choose: 'a list -> 'a t
(** [uniform lst] Generate a random value of the list [lst].
Precondition: List must not be empty [lst <> []]
*)
end
(** Posix Time *)
module Time:
sig
(** Posix time is the number of milliseconds passed since the beginning of
the unix epoch i.e. since 1.1.1970 in utc i.e. universal coordinated
time.
In order to get the time in your time zone you need a time zone.
*)
(** Time zone *)
module Zone:
sig
(** A time zone is the offset in minutes from utc. Time zones westward
of utc get a positive offset, eastward of utc a negative offset.
*)
type t
val utc: t
val make: int -> t
(** [make offset] Time zone [offset] minutes westward of utc.
[make (-60)] is the zone of central european winter time. It is one
hour eastward of utc.
*)
val offset: t -> int
(** [offset zone] The offset of [zone] in minutes westward of utc. *)
end
type t
val zero: t
(** [1.1.1970] in utc. *)
val of_float: float -> t
val to_float: t -> float
(** In order to get a year, month, ... you need the utc time and the time
zone you are in. *)
val year: t -> Zone.t -> int
(** [year time zone] The year of [time] in [zone]. *)
val month: t -> Zone.t -> int
(** [month time zone] The month of [time] in [zone].
January is month [0].
*)
val day_of_month: t -> Zone.t -> int
(** [day_of_month time zone] The day of the month of [time] in [zone].
First day of the month is day [0].
*)
val hour: t -> Zone.t -> int
(** 0 - 23 *)
val minute: t -> Zone.t -> int
(** 0 - 59 *)
val second: t -> Zone.t -> int
(** 0 - 59 *)
val milli_second: t -> Zone.t -> int
(** 0 - 999 *)
end
(** Event flags to stop propagation and prevent default action. *)
module Event_flag:
sig
type prevent
type stop
val prevent: prevent
(** Prevent default handling. *)
val no_prevent: prevent
(** Do not prevent default handling. *)
val stop: stop
(** Stop event propagation. *)
val no_stop: stop
(** Do not stop event propagation. *)
end
(** {1 Encode and Decode Javascript Values} *)
(** Javascript Values
Javascript values are necessary to comunicate with the javascript world. In
order to send a message to the surrounding javascript (see
{!val: Task.send_to_javascript}) a javascript value is needed. The following
functions can be used to construct arbitrary javascript values (no
functions, just data).
E.g. if you want to construct the javascript object
{v
{first_name: "John", last_name: "Doe", age: 45}
v}
you just write
{[
record
[|
"first_name", string "John"
; "last_name", string "Doe"
; "age", int 45
|]
]}
*)
module Value:
sig
type t
val null: t (** The javascript value [null] *)
val string: string -> t
(** [string str] The javascript string [str] *)
val int: int -> t
(** [int 5] The javascript number [5]. *)
val bool: bool -> t
(** [bool true] The javascript value [true]. *)
val float: float -> t
(** [float 5] The javascript number [5]. *)
val record: (string * t) array -> t
(** [record [| "a", int 5; "b", string "hello"|]] is the javascript value
[{a: 5, b: 'hello'}|].
*)
val array: t array -> t
(** [array [|int 5; string "hello"; bool true|] ] is the javascript array
[[5, "hello", true]].
*)
end
(** Decoder for Javascript Values *)
module Decoder:
sig
(** {1 Overview}
Suppose we have the following ocaml types
{[
type sex = Male | Female
type tp = {
name: string;
age: int;
sex: sex
}
]}
and we want to decode the javascript object
{[
{name: "Jonathan", sex: "male", age: 55}
]}
The we can use the following decoder
{[
let decode: tp Decode.t =
let open Decode in
let* name = field "name" string in
let* age = field "age" int in
let* sex =
field
"sex"
(
let* str = string in
match str with
| "male" ->
return Male
| "female" ->
return Female
| _ ->
fail
)
in
return {name; age; sex}
]}
The decoder [decode] decodes any javascript object which has the fields
[name] [age] and [sex] with a value of the appropriate type into the
corresponding ocaml record.
*)
(** {1 API} *)
(** {1 General}
*)
type 'a t
(** ['a t] Type of a decoder which decodes a javascript value into an
optional object of type ['a].
*)
val run: 'a t -> Value.t -> 'a option
(** [run decoder value] Run the decoder on a javascript value. If the
decoder succeeds with value [a], then return [Some a]. Otherwise return
[None].
*)
val return: 'a -> 'a t
(** [return a] Succeed with [a] regardless what the javascript object is. *)
val fail: 'a t
(** Fail immediately. *)
val (>>=): 'a t -> ('a -> 'b t) -> 'b t
(** [dec >>= f]
Equivalent to
{[
let* v = dec in
f v
]}
*)
val ( let* ): 'a t -> ('a -> 'b t) -> 'b t
(** Combine decoders.
Example:
{[
let* a = dec1 in
dec2 a
]}
First decode the javascript value with decoder [dec1]. In case of
success with the value [a], use decoder [dec2] which can depend on
[a].
[let*] is useful to decode various fields of an object.
{[
let* f1 = field "name1" dec1 in
let* f2 = field "name2" dec2 in
...
return ...
]}
*)
val map: ('a -> 'b) -> 'a t -> 'b t
(** [map f dec] Decode using [dec] and in case of success, map the decoded
value [a] to [f a]. *)
val (</>): 'a t -> 'a t -> 'a t
(** [dec1 </> dec2] First try decoder [dec1]. If it succeeds, return the
decoded value. In case [dec1] fails, use [dec2] to decode the javascript
value.
*)
(** {1 Basic decoders}
*)
val null: 'a -> 'a t
(** [null v] If the javascript value is [null], then return [v]. Otherwise
fail.
*)
val undefined: 'a -> 'a t
(** [undefined v] If the javascript value is [undefined], then return [v].
Otherwise fail.
*)
val int: int t
(** Decode an integer value i.e. a number between [-2^31] and [2^31 - 1].
*)
val bool: bool t
(** Decode a boolean value. *)
val float: float t
(** Decode a floating point value i.e. a number. *)
val string: string t
(** Decode a string value. The decoding converts the javascript string from
utf16 into an ocaml utf8 string.
*)
(** {1 Complex decoders}
*)
val field: string -> 'a t -> 'a t
(** [field name dec] Decode the field named [name] in the javascript object
with the decoder [dec].
*)
val array: 'a t -> 'a array t
(** [array dec] Decode a javascript array into an ocaml array using [dec] to
decode elements.
*)
val option: 'a t -> 'a option t
(** [option dec] In case the javascript object is [null] succeed with [None].
Otherwise use [dec] to decode the object and in case of success wrap the
result with [Some].
Examples:
{[
run (option int) Value.null ~> Some None
run (option int) (Value.int 5) ~> Some (Some 5)
run (option int) (Value.string "a") ~> None
]}
*)
end
(** {1 Virtual Dom} *)
(** Attributes of Dom Elements.
There are four types of attributes:
- style attributes: Color, font size, etc.
- property attributes: arbitrary javascript values as properties of the
corresponding dom element.
- attributes: string valued attributes to give the element an id, a
classname, etc.
- handler attributes: React to user interactions (mouse clicks, ...) on the
html element.
Sometimes the distinction between properties and attributes is quite subtle.
To the best of my knowledge each added attribute adds a property with the
same name (except when the name is a javascript keyword like "class") to the
html element. But not all properties even if it is a string value adds
an attribute to the element.
*)
module Attribute:
sig
(** {1 Generic Interface}
*)
type 'msg t (** Type of an attribute potentially generating a message of
type ['msg]. *)
val style: string -> string -> 'msg t
(** [style key value] Add a style attribute to the html element.
Examples:
{[
style "color" "red"
style "margin" "20px"
]}
*)
val property: string -> Value.t -> 'msg t
(** [property key value] Add a javascript property to the html element. *)
val attribute: string -> string -> 'msg t
(** [attribute key value] Add an attribute to the html element.
Examples:
{[
attribute "id" "my_element"
attribute "class" "container"
]}
*)
val handler:
string
-> Event_flag.stop
-> Event_flag.prevent
-> 'msg Decoder.t
-> 'msg t
(** [handler event_type stop_flag prevent_flag decoder]
Attribute representing an event listener on an html element. The two
flags decide if the event is propagated upwards in the dom tree and if
default action (some events like clicking on an anchor element cause
default actions in the browser) is prevented.
The decoder decodes the javascript event object into a message of type
['msg].
Starting from the event object information from the whole dom tree up to
the root can be decode. Each event object has a target (which is the
element on which it is fired). The target element has a tag name, can
have various properties etc. For more details on event objects see the
{{: https://developer.mozilla.org/en-US/docs/Web/API/Event} event api}.
More information on {{!page-doc_event_handler} event handlers}.
*)
val map: ('a -> 'b) -> 'a t -> 'b t
(** [map f a] Map an attribute creating messages of type ['a] to an
attribute creating messages of type ['b].
*)
(** {1 Handler} *)
val on: string -> 'msg Decoder.t -> 'msg t
(** [on event_type decoder]
is equivalent to
[handler event_type Event_flag.no_stop Event_flag.no_prevent decoder]
*)
val on_click: 'msg -> 'msg t
(** [on_click m] produce the message [m] on mouse click. *)
(** {1 Common style attributes} *)
val font_size: string -> 'msg t
(** Example [font_size "20px"]
Abbreviates [style "font-size" "20px"].
*)
val color: string -> 'msg t
(** Example [color "red"]
Abbreviates [style "color" "red"].
*)
val background_color: string -> 'msg t
(** Example [background_color "powderblue"]
Abbreviates [style "background-color" "powderblue"].
*)
val height: string -> 'msg t
(** Example [height "200px"]
Abbreviates [style "height" "200px"].
*)
val width: string -> 'msg t
(** Example [width "200px"]
Abbreviates [style "width" "200px"].
*)
(** {1 Margin, border, padding and content}
{v
+--------------------------------+
| margin |
| +----border-----------------+ |
| | padding | |
| | +---------------------+ | |
| | | | | |
| | | | | |
| | | content | | |
| | | | | |
| | +---------------------+ | |
| +---------------------------+ |
| |
+--------------------------------+
v}
*)
val margin: string -> 'msg t
(** Examples
{[
margin "25px"
margin "25px 50px" top/bottom 25px, left/right 50px
margin "25px 50px 75px 100px" top, right, bottom, left
]}
[margin str] abbreviates [style "margin" str]
*)
val padding: string -> 'msg t
(** Examples
{[
padding "25px"
padding "25px 50px" top/bottom 25px, left/right 50px
padding "25px 50px 75px 100px" top, right, bottom, left
]}
[padding str] abbreviates [style "padding" str]
*)
val border_style: string -> 'msg t
(** Examples
{[
border_style "solid"
border_style "dotted"
border_style "dashed"
]}
[border_style str] abbreviates [style "border-style" str]
*)
val border_width: string -> 'msg t
(** Examples
{[
border_width "3px"
border_width "thick"
border_width "medium"
]}
*)
val border_color: string -> 'msg t
(** Example
{[
border_color "red"
]}
*)
(** {1 Common attributes} *)
val id: string -> 'msg t
(** "id" attribute *)
val class_: string -> 'msg t
(** "class" attribute *)
val href: string -> 'msg t
(** "href" attribute *)
val src: string -> 'msg t
(** "src" attribute *)
val title: string -> 'msg t
(** "title" attribute to display tooltips *)
(** {1 Input elements} *)
val value: string -> 'msg t
(** The [value] property of the element (usually an input element)
Each time the user enters something to the input element (text for input
type 'text', slider position for input type 'range', date for input type
'date'), the value property changes. Using the value property in the
virtual dom overwrites whatever the user has written into the input
element. Using a 'value' attribute in the virtual dom does *not*
overwrite the user value.
*)
val placeholder: string -> 'msg t
val on_input: (string -> 'msg) -> 'msg t
end
(** Virtual Dom *)
module Html:
sig
(** {1 Primitives}
*)
type 'msg t (** Type of a virtual dom node potentially generating a message
of type ['msg]. *)
val text: string -> 'msg t (** [text str] Create a text node. *)
val node: string -> 'msg Attribute.t list -> 'msg t list -> 'msg t
(** [node tag attrs children]
Create an html element with a tagname, a list of attributes and a list
of children.
*)
val node_ns:
string -> string -> 'msg Attribute.t list -> 'msg t list -> 'msg t
(** [node namespace tag attrs children]
Like [node], but creates the node within a namespace e.g.
"http://www.w3.org/2000/svg" for [svg] elements.
*)
val svg_node: string -> 'msg Attribute.t list -> 'msg t list -> 'msg t
(** [svg_node tag attrs children]
Create an svg element with a tagname, a list of attributes and a list
of children. An svg element is a node in the namespace
"http://www.w3.org/2000/svg".
*)
val map: ('a -> 'b) -> 'a t -> 'b t
(** [map f vdom]
Map a virtual dom [vdom] creating messages of type ['a] to a virtual dom
creating messages of type ['b].
*)
val keyed:
string -> 'msg Attribute.t list -> (string * 'msg t) list -> 'msg t
(** [keyed tag attrs children]
Like [node], but add a unique identifier to each child node. This makes
adding, removing and modifying child nodes more efficient. The dom
diffing algorithm compares child nodes with the same identifier.
*)
(** {1 Headers}
*)
val h1: 'msg Attribute.t list -> 'msg t list -> 'msg t
(** [h1 attrs children] is equivalent to [node "h1" attrs children]. *)
val h2: 'msg Attribute.t list -> 'msg t list -> 'msg t
(** [h2 attrs children] is equivalent to [node "h2" attrs children]. *)
val h3: 'msg Attribute.t list -> 'msg t list -> 'msg t
(** [h3 attrs children] is equivalent to [node "h3" attrs children]. *)
val h4: 'msg Attribute.t list -> 'msg t list -> 'msg t
(** [h4 attrs children] is equivalent to [node "h4" attrs children]. *)
val h5: 'msg Attribute.t list -> 'msg t list -> 'msg t
(** [h5 attrs children] is equivalent to [node "h5" attrs children]. *)
val h6: 'msg Attribute.t list -> 'msg t list -> 'msg t
(** [h6 attrs children] is equivalent to [node "h6" attrs children]. *)
(** {1 Grouping Content}
*)
val div: 'msg Attribute.t list -> 'msg t list -> 'msg t
(** [div attrs children] is equivalent to [node "div" attrs children]. *)
val span: 'msg Attribute.t list -> 'msg t list -> 'msg t
(** [span attrs children] is equivalent to [node "span" attrs children]. *)
val pre: 'msg Attribute.t list -> 'msg t list -> 'msg t
(** [pre attrs children] is equivalent to [node "pre" attrs children]. *)
val p: 'msg Attribute.t list -> 'msg t list -> 'msg t
(** [p attrs children] is equivalent to [node "p" attrs children]. *)
(** {1 Input}
*)
val button: 'msg Attribute.t list -> 'msg t list -> 'msg t
(** [button attrs children] is equivalent to [node "button" attrs children]. *)
val input: 'msg Attribute.t list -> 'msg t list -> 'msg t
(** [input attrs children] is equivalent to [node "input" attrs children]. *)
val label: 'msg Attribute.t list -> 'msg t list -> 'msg t
(** [label attrs children] is equivalent to [node "label" attrs children]. *)
val textarea: 'msg Attribute.t list -> 'msg t list -> 'msg t
(** [textarea attrs children] is equivalent to
[node "textarea" attrs children]. *)
val select: 'msg Attribute.t list -> 'msg t list -> 'msg t
(** [select attrs children] is equivalent to [node "select" attrs children]. *)
(** {1 Lists}
*)
val ol: 'msg Attribute.t list -> 'msg t list -> 'msg t
(** [ol attrs children] is equivalent to [node "ol" attrs children]. *)
val ul: 'msg Attribute.t list -> 'msg t list -> 'msg t
(** [ul attrs children] is equivalent to [node "ul" attrs children]. *)
val li: 'msg Attribute.t list -> 'msg t list -> 'msg t
(** [li attrs children] is equivalent to [node "li" attrs children]. *)
end
(** {1 Commands and Subscriptions} *)
(** Tasks to be performed within {{!module:Command} Commands} *)
module Task:
sig
(** {1 Error types} *)
type empty = []
type http_error = [
| `Http_status of int
(**
- 0: no internet, server not found, timeout, ...
- 401: bad request
- 403: forbidden
- 404: page not found
- ...
*)
| `Http_no_json (** Resource is not a valid json file *)
| `Http_decode (** Resource is a valid json file, but the decoder could
not decode the corresponding javascript object. *)
]
type not_found = [`Not_found]
(** {1 Basic type and functions} *)
type ('a, +'e) t
(** Task succeeding with a value of type ['a] or failing with
an error object of type ['e] *)
val succeed: 'a -> ('a, 'e) t
(** [succeed a] Task which immediately succeeds with value [a]. *)
val return: 'a -> ('a, 'e) t
(** Same as {!succeed}. *)
val fail: 'e -> ('a, 'e) t
(** [fail e] Task which immediately fails with the error [e]. *)
val result: ('a, 'e) result -> ('a, 'e) t
(** [result res] Task which immediately succeeds or fails depending on [res]
The effect of the function is described by the code
{[
match res with
| Ok a -> succeed a
| Error e -> fail e
]}
*)
val (>>=): ('a, 'e) t -> ('a -> ('b, 'e) t) -> ('b, 'e) t
(** [task >>= f]
First execute [task]. If it fails then the function fails. If [task]
succeeds with the result [a] then execute the task [f a].
*)
val ( let* ): ('a, 'e) t -> ('a -> ('b, 'e) t) -> ('b, 'e) t
(** More convenient syntax for the monadic bind operator {!(>>=)}.
The code
{[
let* a = task in
f a
]}
is equivalent to
{[
task >>= f
]}
With the [let*] operator it is more convenient to chain tasks.
{[
let* a = t1 in
let* b = t2 a in
let* c = t3 a b in
...
return f a b c ...
]}
*)
val map: ('a -> 'b) -> ('a, 'e) t -> ('b, 'e) t
(** [map f task] Map the success result of [task] via the function [f]. *)
val make_succeed: (('a, 'e) result -> 'b) -> ('a, 'e) t -> ('b, empty) t
(** [make_succeed f task]
Convert the task which might fail into a task which always succeeds by
converting the positive or negative result via the function [f] into a
new result.
*)
val parallel:
'accu -> ('a -> 'accu -> 'accu)
-> ('a, empty) t list
-> ('accu, empty) t
(** [parallel accu_start accumulate task_list]
Run all the tasks in the task list in parallel. Collect the results of
the individual tasks via the function [accumulate] into the accumulator.
If all tasks of the list have finished, return the accumulator.
Note that the tasks of the list do not return errors. If they can have
errors then {!make_succeed} can be used to encode the error into the
result type ['a].
*)