-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
11502 lines (10383 loc) · 336 KB
/
index.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
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
<!DOCTYPE HTML>
<html><head><meta charset="UTF-8"><title>Main</title><style>html,head,body { padding:0; margin:0; }
body { font-family: calibri, helvetica, arial, sans-serif; }</style><script type="text/javascript">var Elm = Elm || { Native: {} };Elm.Native.Basics = {};
Elm.Native.Basics.make = function(localRuntime) {
localRuntime.Native = localRuntime.Native || {};
localRuntime.Native.Basics = localRuntime.Native.Basics || {};
if (localRuntime.Native.Basics.values)
{
return localRuntime.Native.Basics.values;
}
var Utils = Elm.Native.Utils.make(localRuntime);
function div(a, b)
{
return (a / b) | 0;
}
function rem(a, b)
{
return a % b;
}
function mod(a, b)
{
if (b === 0)
{
throw new Error('Cannot perform mod 0. Division by zero error.');
}
var r = a % b;
var m = a === 0 ? 0 : (b > 0 ? (a >= 0 ? r : r + b) : -mod(-a, -b));
return m === b ? 0 : m;
}
function logBase(base, n)
{
return Math.log(n) / Math.log(base);
}
function negate(n)
{
return -n;
}
function abs(n)
{
return n < 0 ? -n : n;
}
function min(a, b)
{
return Utils.cmp(a, b) < 0 ? a : b;
}
function max(a, b)
{
return Utils.cmp(a, b) > 0 ? a : b;
}
function clamp(lo, hi, n)
{
return Utils.cmp(n, lo) < 0 ? lo : Utils.cmp(n, hi) > 0 ? hi : n;
}
function xor(a, b)
{
return a !== b;
}
function not(b)
{
return !b;
}
function isInfinite(n)
{
return n === Infinity || n === -Infinity;
}
function truncate(n)
{
return n | 0;
}
function degrees(d)
{
return d * Math.PI / 180;
}
function turns(t)
{
return 2 * Math.PI * t;
}
function fromPolar(point)
{
var r = point._0;
var t = point._1;
return Utils.Tuple2(r * Math.cos(t), r * Math.sin(t));
}
function toPolar(point)
{
var x = point._0;
var y = point._1;
return Utils.Tuple2(Math.sqrt(x * x + y * y), Math.atan2(y, x));
}
return localRuntime.Native.Basics.values = {
div: F2(div),
rem: F2(rem),
mod: F2(mod),
pi: Math.PI,
e: Math.E,
cos: Math.cos,
sin: Math.sin,
tan: Math.tan,
acos: Math.acos,
asin: Math.asin,
atan: Math.atan,
atan2: F2(Math.atan2),
degrees: degrees,
turns: turns,
fromPolar: fromPolar,
toPolar: toPolar,
sqrt: Math.sqrt,
logBase: F2(logBase),
negate: negate,
abs: abs,
min: F2(min),
max: F2(max),
clamp: F3(clamp),
compare: Utils.compare,
xor: F2(xor),
not: not,
truncate: truncate,
ceiling: Math.ceil,
floor: Math.floor,
round: Math.round,
toFloat: function(x) { return x; },
isNaN: isNaN,
isInfinite: isInfinite
};
};
Elm.Native.Port = {};
Elm.Native.Port.make = function(localRuntime) {
localRuntime.Native = localRuntime.Native || {};
localRuntime.Native.Port = localRuntime.Native.Port || {};
if (localRuntime.Native.Port.values)
{
return localRuntime.Native.Port.values;
}
var NS;
// INBOUND
function inbound(name, type, converter)
{
if (!localRuntime.argsTracker[name])
{
throw new Error(
'Port Error:\n' +
'No argument was given for the port named \'' + name + '\' with type:\n\n' +
' ' + type.split('\n').join('\n ') + '\n\n' +
'You need to provide an initial value!\n\n' +
'Find out more about ports here <http://elm-lang.org/learn/Ports.elm>'
);
}
var arg = localRuntime.argsTracker[name];
arg.used = true;
return jsToElm(name, type, converter, arg.value);
}
function inboundSignal(name, type, converter)
{
var initialValue = inbound(name, type, converter);
if (!NS)
{
NS = Elm.Native.Signal.make(localRuntime);
}
var signal = NS.input('inbound-port-' + name, initialValue);
function send(jsValue)
{
var elmValue = jsToElm(name, type, converter, jsValue);
setTimeout(function() {
localRuntime.notify(signal.id, elmValue);
}, 0);
}
localRuntime.ports[name] = { send: send };
return signal;
}
function jsToElm(name, type, converter, value)
{
try
{
return converter(value);
}
catch(e)
{
throw new Error(
'Port Error:\n' +
'Regarding the port named \'' + name + '\' with type:\n\n' +
' ' + type.split('\n').join('\n ') + '\n\n' +
'You just sent the value:\n\n' +
' ' + JSON.stringify(value) + '\n\n' +
'but it cannot be converted to the necessary type.\n' +
e.message
);
}
}
// OUTBOUND
function outbound(name, converter, elmValue)
{
localRuntime.ports[name] = converter(elmValue);
}
function outboundSignal(name, converter, signal)
{
var subscribers = [];
function subscribe(handler)
{
subscribers.push(handler);
}
function unsubscribe(handler)
{
subscribers.pop(subscribers.indexOf(handler));
}
function notify(elmValue)
{
var jsValue = converter(elmValue);
var len = subscribers.length;
for (var i = 0; i < len; ++i)
{
subscribers[i](jsValue);
}
}
if (!NS)
{
NS = Elm.Native.Signal.make(localRuntime);
}
NS.output('outbound-port-' + name, notify, signal);
localRuntime.ports[name] = {
subscribe: subscribe,
unsubscribe: unsubscribe
};
return signal;
}
return localRuntime.Native.Port.values = {
inbound: inbound,
outbound: outbound,
inboundSignal: inboundSignal,
outboundSignal: outboundSignal
};
};
if (!Elm.fullscreen) {
(function() {
'use strict';
var Display = {
FULLSCREEN: 0,
COMPONENT: 1,
NONE: 2
};
Elm.fullscreen = function(module, args)
{
var container = document.createElement('div');
document.body.appendChild(container);
return init(Display.FULLSCREEN, container, module, args || {});
};
Elm.embed = function(module, container, args)
{
var tag = container.tagName;
if (tag !== 'DIV')
{
throw new Error('Elm.node must be given a DIV, not a ' + tag + '.');
}
return init(Display.COMPONENT, container, module, args || {});
};
Elm.worker = function(module, args)
{
return init(Display.NONE, {}, module, args || {});
};
function init(display, container, module, args, moduleToReplace)
{
// defining state needed for an instance of the Elm RTS
var inputs = [];
/* OFFSET
* Elm's time traveling debugger lets you pause time. This means
* "now" may be shifted a bit into the past. By wrapping Date.now()
* we can manage this.
*/
var timer = {
programStart: Date.now(),
now: function()
{
return Date.now();
}
};
var updateInProgress = false;
function notify(id, v)
{
if (updateInProgress)
{
throw new Error(
'The notify function has been called synchronously!\n' +
'This can lead to frames being dropped.\n' +
'Definitely report this to <https://github.com/elm-lang/Elm/issues>\n');
}
updateInProgress = true;
var timestep = timer.now();
for (var i = inputs.length; i--; )
{
inputs[i].notify(timestep, id, v);
}
updateInProgress = false;
}
function setTimeout(func, delay)
{
return window.setTimeout(func, delay);
}
var listeners = [];
function addListener(relevantInputs, domNode, eventName, func)
{
domNode.addEventListener(eventName, func);
var listener = {
relevantInputs: relevantInputs,
domNode: domNode,
eventName: eventName,
func: func
};
listeners.push(listener);
}
var argsTracker = {};
for (var name in args)
{
argsTracker[name] = {
value: args[name],
used: false
};
}
// create the actual RTS. Any impure modules will attach themselves to this
// object. This permits many Elm programs to be embedded per document.
var elm = {
notify: notify,
setTimeout: setTimeout,
node: container,
addListener: addListener,
inputs: inputs,
timer: timer,
argsTracker: argsTracker,
ports: {},
isFullscreen: function() { return display === Display.FULLSCREEN; },
isEmbed: function() { return display === Display.COMPONENT; },
isWorker: function() { return display === Display.NONE; }
};
function swap(newModule)
{
removeListeners(listeners);
var div = document.createElement('div');
var newElm = init(display, div, newModule, args, elm);
inputs = [];
return newElm;
}
function dispose()
{
removeListeners(listeners);
inputs = [];
}
var Module = {};
try
{
Module = module.make(elm);
checkInputs(elm);
}
catch (error)
{
if (typeof container.appendChild === "function")
{
container.appendChild(errorNode(error.message));
}
else
{
console.error(error.message);
}
throw error;
}
if (display !== Display.NONE)
{
var graphicsNode = initGraphics(elm, Module);
}
var rootNode = { kids: inputs };
trimDeadNodes(rootNode);
inputs = rootNode.kids;
filterListeners(inputs, listeners);
addReceivers(elm.ports);
if (typeof moduleToReplace !== 'undefined')
{
hotSwap(moduleToReplace, elm);
// rerender scene if graphics are enabled.
if (typeof graphicsNode !== 'undefined')
{
graphicsNode.notify(0, true, 0);
}
}
return {
swap: swap,
ports: elm.ports,
dispose: dispose
};
}
function checkInputs(elm)
{
var argsTracker = elm.argsTracker;
for (var name in argsTracker)
{
if (!argsTracker[name].used)
{
throw new Error(
"Port Error:\nYou provided an argument named '" + name +
"' but there is no corresponding port!\n\n" +
"Maybe add a port '" + name + "' to your Elm module?\n" +
"Maybe remove the '" + name + "' argument from your initialization code in JS?"
);
}
}
}
function errorNode(message)
{
var code = document.createElement('code');
var lines = message.split('\n');
code.appendChild(document.createTextNode(lines[0]));
code.appendChild(document.createElement('br'));
code.appendChild(document.createElement('br'));
for (var i = 1; i < lines.length; ++i)
{
code.appendChild(document.createTextNode('\u00A0 \u00A0 ' + lines[i].replace(/ /g, '\u00A0 ')));
code.appendChild(document.createElement('br'));
}
code.appendChild(document.createElement('br'));
code.appendChild(document.createTextNode('Open the developer console for more details.'));
return code;
}
//// FILTER SIGNALS ////
// TODO: move this code into the signal module and create a function
// Signal.initializeGraph that actually instantiates everything.
function filterListeners(inputs, listeners)
{
loop:
for (var i = listeners.length; i--; )
{
var listener = listeners[i];
for (var j = inputs.length; j--; )
{
if (listener.relevantInputs.indexOf(inputs[j].id) >= 0)
{
continue loop;
}
}
listener.domNode.removeEventListener(listener.eventName, listener.func);
}
}
function removeListeners(listeners)
{
for (var i = listeners.length; i--; )
{
var listener = listeners[i];
listener.domNode.removeEventListener(listener.eventName, listener.func);
}
}
// add receivers for built-in ports if they are defined
function addReceivers(ports)
{
if ('title' in ports)
{
if (typeof ports.title === 'string')
{
document.title = ports.title;
}
else
{
ports.title.subscribe(function(v) { document.title = v; });
}
}
if ('redirect' in ports)
{
ports.redirect.subscribe(function(v) {
if (v.length > 0)
{
window.location = v;
}
});
}
}
// returns a boolean representing whether the node is alive or not.
function trimDeadNodes(node)
{
if (node.isOutput)
{
return true;
}
var liveKids = [];
for (var i = node.kids.length; i--; )
{
var kid = node.kids[i];
if (trimDeadNodes(kid))
{
liveKids.push(kid);
}
}
node.kids = liveKids;
return liveKids.length > 0;
}
//// RENDERING ////
function initGraphics(elm, Module)
{
if (!('main' in Module))
{
throw new Error("'main' is missing! What do I display?!");
}
var signalGraph = Module.main;
// make sure the signal graph is actually a signal & extract the visual model
if (!('notify' in signalGraph))
{
signalGraph = Elm.Signal.make(elm).constant(signalGraph);
}
var initialScene = signalGraph.value;
// Figure out what the render functions should be
var render;
var update;
if (initialScene.ctor === 'Element_elm_builtin')
{
var Element = Elm.Native.Graphics.Element.make(elm);
render = Element.render;
update = Element.updateAndReplace;
}
else
{
var VirtualDom = Elm.Native.VirtualDom.make(elm);
render = VirtualDom.render;
update = VirtualDom.updateAndReplace;
}
// Add the initialScene to the DOM
var container = elm.node;
var node = render(initialScene);
while (container.firstChild)
{
container.removeChild(container.firstChild);
}
container.appendChild(node);
var _requestAnimationFrame =
typeof requestAnimationFrame !== 'undefined'
? requestAnimationFrame
: function(cb) { setTimeout(cb, 1000 / 60); }
;
// domUpdate is called whenever the main Signal changes.
//
// domUpdate and drawCallback implement a small state machine in order
// to schedule only 1 draw per animation frame. This enforces that
// once draw has been called, it will not be called again until the
// next frame.
//
// drawCallback is scheduled whenever
// 1. The state transitions from PENDING_REQUEST to EXTRA_REQUEST, or
// 2. The state transitions from NO_REQUEST to PENDING_REQUEST
//
// Invariants:
// 1. In the NO_REQUEST state, there is never a scheduled drawCallback.
// 2. In the PENDING_REQUEST and EXTRA_REQUEST states, there is always exactly 1
// scheduled drawCallback.
var NO_REQUEST = 0;
var PENDING_REQUEST = 1;
var EXTRA_REQUEST = 2;
var state = NO_REQUEST;
var savedScene = initialScene;
var scheduledScene = initialScene;
function domUpdate(newScene)
{
scheduledScene = newScene;
switch (state)
{
case NO_REQUEST:
_requestAnimationFrame(drawCallback);
state = PENDING_REQUEST;
return;
case PENDING_REQUEST:
state = PENDING_REQUEST;
return;
case EXTRA_REQUEST:
state = PENDING_REQUEST;
return;
}
}
function drawCallback()
{
switch (state)
{
case NO_REQUEST:
// This state should not be possible. How can there be no
// request, yet somehow we are actively fulfilling a
// request?
throw new Error(
'Unexpected draw callback.\n' +
'Please report this to <https://github.com/elm-lang/core/issues>.'
);
case PENDING_REQUEST:
// At this point, we do not *know* that another frame is
// needed, but we make an extra request to rAF just in
// case. It's possible to drop a frame if rAF is called
// too late, so we just do it preemptively.
_requestAnimationFrame(drawCallback);
state = EXTRA_REQUEST;
// There's also stuff we definitely need to draw.
draw();
return;
case EXTRA_REQUEST:
// Turns out the extra request was not needed, so we will
// stop calling rAF. No reason to call it all the time if
// no one needs it.
state = NO_REQUEST;
return;
}
}
function draw()
{
update(elm.node.firstChild, savedScene, scheduledScene);
if (elm.Native.Window)
{
elm.Native.Window.values.resizeIfNeeded();
}
savedScene = scheduledScene;
}
var renderer = Elm.Native.Signal.make(elm).output('main', domUpdate, signalGraph);
// must check for resize after 'renderer' is created so
// that changes show up.
if (elm.Native.Window)
{
elm.Native.Window.values.resizeIfNeeded();
}
return renderer;
}
//// HOT SWAPPING ////
// Returns boolean indicating if the swap was successful.
// Requires that the two signal graphs have exactly the same
// structure.
function hotSwap(from, to)
{
function similar(nodeOld, nodeNew)
{
if (nodeOld.id !== nodeNew.id)
{
return false;
}
if (nodeOld.isOutput)
{
return nodeNew.isOutput;
}
return nodeOld.kids.length === nodeNew.kids.length;
}
function swap(nodeOld, nodeNew)
{
nodeNew.value = nodeOld.value;
return true;
}
var canSwap = depthFirstTraversals(similar, from.inputs, to.inputs);
if (canSwap)
{
depthFirstTraversals(swap, from.inputs, to.inputs);
}
from.node.parentNode.replaceChild(to.node, from.node);
return canSwap;
}
// Returns false if the node operation f ever fails.
function depthFirstTraversals(f, queueOld, queueNew)
{
if (queueOld.length !== queueNew.length)
{
return false;
}
queueOld = queueOld.slice(0);
queueNew = queueNew.slice(0);
var seen = [];
while (queueOld.length > 0 && queueNew.length > 0)
{
var nodeOld = queueOld.pop();
var nodeNew = queueNew.pop();
if (seen.indexOf(nodeOld.id) < 0)
{
if (!f(nodeOld, nodeNew))
{
return false;
}
queueOld = queueOld.concat(nodeOld.kids || []);
queueNew = queueNew.concat(nodeNew.kids || []);
seen.push(nodeOld.id);
}
}
return true;
}
}());
function F2(fun)
{
function wrapper(a) { return function(b) { return fun(a,b); }; }
wrapper.arity = 2;
wrapper.func = fun;
return wrapper;
}
function F3(fun)
{
function wrapper(a) {
return function(b) { return function(c) { return fun(a, b, c); }; };
}
wrapper.arity = 3;
wrapper.func = fun;
return wrapper;
}
function F4(fun)
{
function wrapper(a) { return function(b) { return function(c) {
return function(d) { return fun(a, b, c, d); }; }; };
}
wrapper.arity = 4;
wrapper.func = fun;
return wrapper;
}
function F5(fun)
{
function wrapper(a) { return function(b) { return function(c) {
return function(d) { return function(e) { return fun(a, b, c, d, e); }; }; }; };
}
wrapper.arity = 5;
wrapper.func = fun;
return wrapper;
}
function F6(fun)
{
function wrapper(a) { return function(b) { return function(c) {
return function(d) { return function(e) { return function(f) {
return fun(a, b, c, d, e, f); }; }; }; }; };
}
wrapper.arity = 6;
wrapper.func = fun;
return wrapper;
}
function F7(fun)
{
function wrapper(a) { return function(b) { return function(c) {
return function(d) { return function(e) { return function(f) {
return function(g) { return fun(a, b, c, d, e, f, g); }; }; }; }; }; };
}
wrapper.arity = 7;
wrapper.func = fun;
return wrapper;
}
function F8(fun)
{
function wrapper(a) { return function(b) { return function(c) {
return function(d) { return function(e) { return function(f) {
return function(g) { return function(h) {
return fun(a, b, c, d, e, f, g, h); }; }; }; }; }; }; };
}
wrapper.arity = 8;
wrapper.func = fun;
return wrapper;
}
function F9(fun)
{
function wrapper(a) { return function(b) { return function(c) {
return function(d) { return function(e) { return function(f) {
return function(g) { return function(h) { return function(i) {
return fun(a, b, c, d, e, f, g, h, i); }; }; }; }; }; }; }; };
}
wrapper.arity = 9;
wrapper.func = fun;
return wrapper;
}
function A2(fun, a, b)
{
return fun.arity === 2
? fun.func(a, b)
: fun(a)(b);
}
function A3(fun, a, b, c)
{
return fun.arity === 3
? fun.func(a, b, c)
: fun(a)(b)(c);
}
function A4(fun, a, b, c, d)
{
return fun.arity === 4
? fun.func(a, b, c, d)
: fun(a)(b)(c)(d);
}
function A5(fun, a, b, c, d, e)
{
return fun.arity === 5
? fun.func(a, b, c, d, e)
: fun(a)(b)(c)(d)(e);
}
function A6(fun, a, b, c, d, e, f)
{
return fun.arity === 6
? fun.func(a, b, c, d, e, f)
: fun(a)(b)(c)(d)(e)(f);
}
function A7(fun, a, b, c, d, e, f, g)
{
return fun.arity === 7
? fun.func(a, b, c, d, e, f, g)
: fun(a)(b)(c)(d)(e)(f)(g);
}
function A8(fun, a, b, c, d, e, f, g, h)
{
return fun.arity === 8
? fun.func(a, b, c, d, e, f, g, h)
: fun(a)(b)(c)(d)(e)(f)(g)(h);
}
function A9(fun, a, b, c, d, e, f, g, h, i)
{
return fun.arity === 9
? fun.func(a, b, c, d, e, f, g, h, i)
: fun(a)(b)(c)(d)(e)(f)(g)(h)(i);
}
}
Elm.Native = Elm.Native || {};
Elm.Native.Utils = {};
Elm.Native.Utils.make = function(localRuntime) {
localRuntime.Native = localRuntime.Native || {};
localRuntime.Native.Utils = localRuntime.Native.Utils || {};
if (localRuntime.Native.Utils.values)
{
return localRuntime.Native.Utils.values;
}
// COMPARISONS
function eq(l, r)
{
var stack = [{'x': l, 'y': r}];
while (stack.length > 0)
{
var front = stack.pop();
var x = front.x;
var y = front.y;
if (x === y)
{
continue;
}
if (typeof x === 'object')
{
var c = 0;
for (var i in x)
{
++c;
if (i in y)
{
if (i !== 'ctor')
{
stack.push({ 'x': x[i], 'y': y[i] });
}
}
else
{
return false;
}
}
if ('ctor' in x)
{
stack.push({'x': x.ctor, 'y': y.ctor});
}
if (c !== Object.keys(y).length)
{
return false;
}
}
else if (typeof x === 'function')
{
throw new Error('Equality error: general function equality is ' +
'undecidable, and therefore, unsupported');
}
else
{
return false;
}
}
return true;
}
// code in Generate/JavaScript.hs depends on the particular
// integer values assigned to LT, EQ, and GT
var LT = -1, EQ = 0, GT = 1, ord = ['LT', 'EQ', 'GT'];
function compare(x, y)
{
return {
ctor: ord[cmp(x, y) + 1]
};
}
function cmp(x, y) {
var ord;
if (typeof x !== 'object')
{
return x === y ? EQ : x < y ? LT : GT;
}
else if (x.isChar)
{
var a = x.toString();
var b = y.toString();
return a === b
? EQ
: a < b
? LT
: GT;
}
else if (x.ctor === '::' || x.ctor === '[]')
{
while (true)