-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
6040 lines (5863 loc) · 247 KB
/
server.js
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
// Generated by psc-bundle 0.8.5.0
var PS = {};
(function(exports) {
"use strict";
//module App.Model.Date
/*eslint-env node*/
//bla
exports.toISOString = function iso8601(d){
return d.toISOString();
};
exports.dateToSqlForComparing = function(d){
return d.toISOString().replace("T", " ").substr(0, 19);
};
})(PS["App.Model.Date"] = PS["App.Model.Date"] || {});
(function(exports) {
/* global exports */
"use strict";
exports.nowImpl = function (ctor) {
return function () {
return ctor(new Date());
};
};
exports.jsDateConstructor = function (x) {
return new Date(x);
};
// jshint maxparams: 2
exports.jsDateMethod = function (method, date) {
return date[method]();
};
// jshint maxparams: 3
exports.strictJsDate = function (just, nothing, s) {
var epoch = Date.parse(s);
if (isNaN(epoch)) return nothing;
var date = new Date(epoch);
var s2 = date.toISOString();
var idx = s2.indexOf(s);
return idx < 0 ? nothing : just(date);
};
})(PS["Data.Date"] = PS["Data.Date"] || {});
(function(exports) {
/* global exports */
"use strict";
// module Prelude
//- Functor --------------------------------------------------------------------
exports.arrayMap = function (f) {
return function (arr) {
var l = arr.length;
var result = new Array(l);
for (var i = 0; i < l; i++) {
result[i] = f(arr[i]);
}
return result;
};
};
//- Eq -------------------------------------------------------------------------
exports.refEq = function (r1) {
return function (r2) {
return r1 === r2;
};
};
//- Ord ------------------------------------------------------------------------
exports.unsafeCompareImpl = function (lt) {
return function (eq) {
return function (gt) {
return function (x) {
return function (y) {
return x < y ? lt : x > y ? gt : eq;
};
};
};
};
};
//- Bounded --------------------------------------------------------------------
exports.topInt = 2147483647;
exports.bottomInt = -2147483648;
//- Show -----------------------------------------------------------------------
exports.showIntImpl = function (n) {
return n.toString();
};
exports.showStringImpl = function (s) {
var l = s.length;
return "\"" + s.replace(
/[\0-\x1F\x7F"\\]/g,
function (c, i) { // jshint ignore:line
switch (c) {
case "\"":
case "\\":
return "\\" + c;
case "\x07": return "\\a";
case "\b": return "\\b";
case "\f": return "\\f";
case "\n": return "\\n";
case "\r": return "\\r";
case "\t": return "\\t";
case "\v": return "\\v";
}
var k = i + 1;
var empty = k < l && s[k] >= "0" && s[k] <= "9" ? "\\&" : "";
return "\\" + c.charCodeAt(0).toString(10) + empty;
}
) + "\"";
};
exports.showArrayImpl = function (f) {
return function (xs) {
var ss = [];
for (var i = 0, l = xs.length; i < l; i++) {
ss[i] = f(xs[i]);
}
return "[" + ss.join(",") + "]";
};
};
})(PS["Prelude"] = PS["Prelude"] || {});
(function(exports) {
// Generated by psc version 0.8.5.0
"use strict";
var $foreign = PS["Prelude"];
var LT = (function () {
function LT() {
};
LT.value = new LT();
return LT;
})();
var GT = (function () {
function GT() {
};
GT.value = new GT();
return GT;
})();
var EQ = (function () {
function EQ() {
};
EQ.value = new EQ();
return EQ;
})();
var Semigroupoid = function (compose) {
this.compose = compose;
};
var Category = function (__superclass_Prelude$dotSemigroupoid_0, id) {
this["__superclass_Prelude.Semigroupoid_0"] = __superclass_Prelude$dotSemigroupoid_0;
this.id = id;
};
var Functor = function (map) {
this.map = map;
};
var Apply = function (__superclass_Prelude$dotFunctor_0, apply) {
this["__superclass_Prelude.Functor_0"] = __superclass_Prelude$dotFunctor_0;
this.apply = apply;
};
var Applicative = function (__superclass_Prelude$dotApply_0, pure) {
this["__superclass_Prelude.Apply_0"] = __superclass_Prelude$dotApply_0;
this.pure = pure;
};
var Bind = function (__superclass_Prelude$dotApply_0, bind) {
this["__superclass_Prelude.Apply_0"] = __superclass_Prelude$dotApply_0;
this.bind = bind;
};
var Monad = function (__superclass_Prelude$dotApplicative_0, __superclass_Prelude$dotBind_1) {
this["__superclass_Prelude.Applicative_0"] = __superclass_Prelude$dotApplicative_0;
this["__superclass_Prelude.Bind_1"] = __superclass_Prelude$dotBind_1;
};
var Semigroup = function (append) {
this.append = append;
};
var Eq = function (eq) {
this.eq = eq;
};
var Ord = function (__superclass_Prelude$dotEq_0, compare) {
this["__superclass_Prelude.Eq_0"] = __superclass_Prelude$dotEq_0;
this.compare = compare;
};
var Bounded = function (bottom, top) {
this.bottom = bottom;
this.top = top;
};
var Show = function (show) {
this.show = show;
};
var unsafeCompare = $foreign.unsafeCompareImpl(LT.value)(EQ.value)(GT.value);
var unit = {};
var top = function (dict) {
return dict.top;
};
var showString = new Show($foreign.showStringImpl);
var showInt = new Show($foreign.showIntImpl);
var show = function (dict) {
return dict.show;
};
var showArray = function (dictShow) {
return new Show($foreign.showArrayImpl(show(dictShow)));
};
var semigroupoidFn = new Semigroupoid(function (f) {
return function (g) {
return function (x) {
return f(g(x));
};
};
});
var pure = function (dict) {
return dict.pure;
};
var $$return = function (dictApplicative) {
return pure(dictApplicative);
};
var otherwise = true;
var map = function (dict) {
return dict.map;
};
var $less$dollar$greater = function (dictFunctor) {
return map(dictFunctor);
};
var id = function (dict) {
return dict.id;
};
var functorArray = new Functor($foreign.arrayMap);
var flip = function (f) {
return function (b) {
return function (a) {
return f(a)(b);
};
};
};
var eqString = new Eq($foreign.refEq);
var ordString = new Ord(function () {
return eqString;
}, unsafeCompare);
var eq = function (dict) {
return dict.eq;
};
var $$const = function (a) {
return function (v) {
return a;
};
};
var $$void = function (dictFunctor) {
return function (fa) {
return $less$dollar$greater(dictFunctor)($$const(unit))(fa);
};
};
var compose = function (dict) {
return dict.compose;
};
var compare = function (dict) {
return dict.compare;
};
var categoryFn = new Category(function () {
return semigroupoidFn;
}, function (x) {
return x;
});
var boundedInt = new Bounded($foreign.bottomInt, $foreign.topInt);
var bottom = function (dict) {
return dict.bottom;
};
var bind = function (dict) {
return dict.bind;
};
var $greater$greater$eq = function (dictBind) {
return bind(dictBind);
};
var apply = function (dict) {
return dict.apply;
};
var $less$times$greater = function (dictApply) {
return apply(dictApply);
};
var liftA1 = function (dictApplicative) {
return function (f) {
return function (a) {
return $less$times$greater(dictApplicative["__superclass_Prelude.Apply_0"]())(pure(dictApplicative)(f))(a);
};
};
};
var append = function (dict) {
return dict.append;
};
var $less$greater = function (dictSemigroup) {
return append(dictSemigroup);
};
var ap = function (dictMonad) {
return function (f) {
return function (a) {
return bind(dictMonad["__superclass_Prelude.Bind_1"]())(f)(function (v) {
return bind(dictMonad["__superclass_Prelude.Bind_1"]())(a)(function (v1) {
return $$return(dictMonad["__superclass_Prelude.Applicative_0"]())(v(v1));
});
});
};
};
};
exports["LT"] = LT;
exports["GT"] = GT;
exports["EQ"] = EQ;
exports["Show"] = Show;
exports["Bounded"] = Bounded;
exports["Ord"] = Ord;
exports["Eq"] = Eq;
exports["Semigroup"] = Semigroup;
exports["Monad"] = Monad;
exports["Bind"] = Bind;
exports["Applicative"] = Applicative;
exports["Apply"] = Apply;
exports["Functor"] = Functor;
exports["Category"] = Category;
exports["Semigroupoid"] = Semigroupoid;
exports["show"] = show;
exports["bottom"] = bottom;
exports["top"] = top;
exports["unsafeCompare"] = unsafeCompare;
exports["compare"] = compare;
exports["eq"] = eq;
exports["<>"] = $less$greater;
exports["append"] = append;
exports["ap"] = ap;
exports["return"] = $$return;
exports[">>="] = $greater$greater$eq;
exports["bind"] = bind;
exports["liftA1"] = liftA1;
exports["pure"] = pure;
exports["<*>"] = $less$times$greater;
exports["apply"] = apply;
exports["void"] = $$void;
exports["<$>"] = $less$dollar$greater;
exports["map"] = map;
exports["id"] = id;
exports["compose"] = compose;
exports["otherwise"] = otherwise;
exports["const"] = $$const;
exports["flip"] = flip;
exports["unit"] = unit;
exports["semigroupoidFn"] = semigroupoidFn;
exports["categoryFn"] = categoryFn;
exports["functorArray"] = functorArray;
exports["eqString"] = eqString;
exports["ordString"] = ordString;
exports["boundedInt"] = boundedInt;
exports["showInt"] = showInt;
exports["showString"] = showString;
exports["showArray"] = showArray;
})(PS["Prelude"] = PS["Prelude"] || {});
(function(exports) {
// Generated by psc version 0.8.5.0
"use strict";
var $$Proxy = (function () {
function Proxy() {
};
Proxy.value = new Proxy();
return Proxy;
})();
exports["Proxy"] = $$Proxy;
})(PS["Type.Proxy"] = PS["Type.Proxy"] || {});
(function(exports) {
/* global exports */
"use strict";
// module Control.Monad.Eff
exports.returnE = function (a) {
return function () {
return a;
};
};
exports.bindE = function (a) {
return function (f) {
return function () {
return f(a())();
};
};
};
exports.runPure = function (f) {
return f();
};
})(PS["Control.Monad.Eff"] = PS["Control.Monad.Eff"] || {});
(function(exports) {
// Generated by psc version 0.8.5.0
"use strict";
var $foreign = PS["Control.Monad.Eff"];
var Prelude = PS["Prelude"];
var monadEff = new Prelude.Monad(function () {
return applicativeEff;
}, function () {
return bindEff;
});
var bindEff = new Prelude.Bind(function () {
return applyEff;
}, $foreign.bindE);
var applyEff = new Prelude.Apply(function () {
return functorEff;
}, Prelude.ap(monadEff));
var applicativeEff = new Prelude.Applicative(function () {
return applyEff;
}, $foreign.returnE);
var functorEff = new Prelude.Functor(Prelude.liftA1(applicativeEff));
exports["functorEff"] = functorEff;
exports["applyEff"] = applyEff;
exports["applicativeEff"] = applicativeEff;
exports["bindEff"] = bindEff;
exports["monadEff"] = monadEff;
exports["runPure"] = $foreign.runPure;
})(PS["Control.Monad.Eff"] = PS["Control.Monad.Eff"] || {});
(function(exports) {
/* global exports */
"use strict";
exports.runFn4 = function (fn) {
return function (a) {
return function (b) {
return function (c) {
return function (d) {
return fn(a, b, c, d);
};
};
};
};
};
})(PS["Data.Function"] = PS["Data.Function"] || {});
(function(exports) {
// Generated by psc version 0.8.5.0
"use strict";
var $foreign = PS["Data.Function"];
var Prelude = PS["Prelude"];
var on = function (f) {
return function (g) {
return function (x) {
return function (y) {
return f(g(x))(g(y));
};
};
};
};
exports["on"] = on;
exports["runFn4"] = $foreign.runFn4;
})(PS["Data.Function"] = PS["Data.Function"] || {});
(function(exports) {
// Generated by psc version 0.8.5.0
"use strict";
var Prelude = PS["Prelude"];
var Alt = function (__superclass_Prelude$dotFunctor_0, alt) {
this["__superclass_Prelude.Functor_0"] = __superclass_Prelude$dotFunctor_0;
this.alt = alt;
};
var alt = function (dict) {
return dict.alt;
};
var $less$bar$greater = function (dictAlt) {
return alt(dictAlt);
};
exports["Alt"] = Alt;
exports["<|>"] = $less$bar$greater;
exports["alt"] = alt;
})(PS["Control.Alt"] = PS["Control.Alt"] || {});
(function(exports) {
// Generated by psc version 0.8.5.0
"use strict";
var Prelude = PS["Prelude"];
var Monoid = function (__superclass_Prelude$dotSemigroup_0, mempty) {
this["__superclass_Prelude.Semigroup_0"] = __superclass_Prelude$dotSemigroup_0;
this.mempty = mempty;
};
var mempty = function (dict) {
return dict.mempty;
};
exports["Monoid"] = Monoid;
exports["mempty"] = mempty;
})(PS["Data.Monoid"] = PS["Data.Monoid"] || {});
(function(exports) {
// Generated by psc version 0.8.5.0
"use strict";
var Prelude = PS["Prelude"];
var Control_Alt = PS["Control.Alt"];
var Control_Alternative = PS["Control.Alternative"];
var Control_Extend = PS["Control.Extend"];
var Control_MonadPlus = PS["Control.MonadPlus"];
var Control_Plus = PS["Control.Plus"];
var Data_Functor_Invariant = PS["Data.Functor.Invariant"];
var Data_Monoid = PS["Data.Monoid"];
var Nothing = (function () {
function Nothing() {
};
Nothing.value = new Nothing();
return Nothing;
})();
var Just = (function () {
function Just(value0) {
this.value0 = value0;
};
Just.create = function (value0) {
return new Just(value0);
};
return Just;
})();
var maybe = function (v) {
return function (v1) {
return function (v2) {
if (v2 instanceof Nothing) {
return v;
};
if (v2 instanceof Just) {
return v1(v2.value0);
};
throw new Error("Failed pattern match at Data.Maybe line 27, column 1 - line 28, column 1: " + [ v.constructor.name, v1.constructor.name, v2.constructor.name ]);
};
};
};
var functorMaybe = new Prelude.Functor(function (v) {
return function (v1) {
if (v1 instanceof Just) {
return new Just(v(v1.value0));
};
return Nothing.value;
};
});
var fromMaybe = function (a) {
return maybe(a)(Prelude.id(Prelude.categoryFn));
};
var applyMaybe = new Prelude.Apply(function () {
return functorMaybe;
}, function (v) {
return function (v1) {
if (v instanceof Just) {
return Prelude["<$>"](functorMaybe)(v.value0)(v1);
};
if (v instanceof Nothing) {
return Nothing.value;
};
throw new Error("Failed pattern match at Data.Maybe line 122, column 3 - line 123, column 3: " + [ v.constructor.name, v1.constructor.name ]);
};
});
var bindMaybe = new Prelude.Bind(function () {
return applyMaybe;
}, function (v) {
return function (v1) {
if (v instanceof Just) {
return v1(v.value0);
};
if (v instanceof Nothing) {
return Nothing.value;
};
throw new Error("Failed pattern match at Data.Maybe line 181, column 3 - line 182, column 3: " + [ v.constructor.name, v1.constructor.name ]);
};
});
var applicativeMaybe = new Prelude.Applicative(function () {
return applyMaybe;
}, Just.create);
exports["Nothing"] = Nothing;
exports["Just"] = Just;
exports["fromMaybe"] = fromMaybe;
exports["maybe"] = maybe;
exports["functorMaybe"] = functorMaybe;
exports["applyMaybe"] = applyMaybe;
exports["applicativeMaybe"] = applicativeMaybe;
exports["bindMaybe"] = bindMaybe;
})(PS["Data.Maybe"] = PS["Data.Maybe"] || {});
(function(exports) {
/* global exports */
"use strict";
// module Data.Foldable
exports.foldrArray = function (f) {
return function (init) {
return function (xs) {
var acc = init;
var len = xs.length;
for (var i = len - 1; i >= 0; i--) {
acc = f(xs[i])(acc);
}
return acc;
};
};
};
exports.foldlArray = function (f) {
return function (init) {
return function (xs) {
var acc = init;
var len = xs.length;
for (var i = 0; i < len; i++) {
acc = f(acc)(xs[i]);
}
return acc;
};
};
};
})(PS["Data.Foldable"] = PS["Data.Foldable"] || {});
(function(exports) {
// Generated by psc version 0.8.5.0
"use strict";
var Prelude = PS["Prelude"];
var $times$greater = function (dictApply) {
return function (a) {
return function (b) {
return Prelude["<*>"](dictApply)(Prelude["<$>"](dictApply["__superclass_Prelude.Functor_0"]())(Prelude["const"](Prelude.id(Prelude.categoryFn)))(a))(b);
};
};
};
exports["*>"] = $times$greater;
})(PS["Control.Apply"] = PS["Control.Apply"] || {});
(function(exports) {
// Generated by psc version 0.8.5.0
"use strict";
var $foreign = PS["Data.Foldable"];
var Prelude = PS["Prelude"];
var Control_Apply = PS["Control.Apply"];
var Data_Maybe = PS["Data.Maybe"];
var Data_Maybe_First = PS["Data.Maybe.First"];
var Data_Maybe_Last = PS["Data.Maybe.Last"];
var Data_Monoid = PS["Data.Monoid"];
var Data_Monoid_Additive = PS["Data.Monoid.Additive"];
var Data_Monoid_Conj = PS["Data.Monoid.Conj"];
var Data_Monoid_Disj = PS["Data.Monoid.Disj"];
var Data_Monoid_Dual = PS["Data.Monoid.Dual"];
var Data_Monoid_Endo = PS["Data.Monoid.Endo"];
var Data_Monoid_Multiplicative = PS["Data.Monoid.Multiplicative"];
var Foldable = function (foldMap, foldl, foldr) {
this.foldMap = foldMap;
this.foldl = foldl;
this.foldr = foldr;
};
var foldr = function (dict) {
return dict.foldr;
};
var traverse_ = function (dictApplicative) {
return function (dictFoldable) {
return function (f) {
return foldr(dictFoldable)(function ($161) {
return Control_Apply["*>"](dictApplicative["__superclass_Prelude.Apply_0"]())(f($161));
})(Prelude.pure(dictApplicative)(Prelude.unit));
};
};
};
var for_ = function (dictApplicative) {
return function (dictFoldable) {
return Prelude.flip(traverse_(dictApplicative)(dictFoldable));
};
};
var foldl = function (dict) {
return dict.foldl;
};
var foldableMaybe = new Foldable(function (dictMonoid) {
return function (f) {
return function (v) {
if (v instanceof Data_Maybe.Nothing) {
return Data_Monoid.mempty(dictMonoid);
};
if (v instanceof Data_Maybe.Just) {
return f(v.value0);
};
throw new Error("Failed pattern match at Data.Foldable line 108, column 3 - line 109, column 3: " + [ f.constructor.name, v.constructor.name ]);
};
};
}, function (v) {
return function (z) {
return function (v1) {
if (v1 instanceof Data_Maybe.Nothing) {
return z;
};
if (v1 instanceof Data_Maybe.Just) {
return v(z)(v1.value0);
};
throw new Error("Failed pattern match at Data.Foldable line 106, column 3 - line 107, column 3: " + [ v.constructor.name, z.constructor.name, v1.constructor.name ]);
};
};
}, function (v) {
return function (z) {
return function (v1) {
if (v1 instanceof Data_Maybe.Nothing) {
return z;
};
if (v1 instanceof Data_Maybe.Just) {
return v(v1.value0)(z);
};
throw new Error("Failed pattern match at Data.Foldable line 104, column 3 - line 105, column 3: " + [ v.constructor.name, z.constructor.name, v1.constructor.name ]);
};
};
});
var foldMapDefaultR = function (dictFoldable) {
return function (dictMonoid) {
return function (f) {
return function (xs) {
return foldr(dictFoldable)(function (x) {
return function (acc) {
return Prelude["<>"](dictMonoid["__superclass_Prelude.Semigroup_0"]())(f(x))(acc);
};
})(Data_Monoid.mempty(dictMonoid))(xs);
};
};
};
};
var foldableArray = new Foldable(function (dictMonoid) {
return foldMapDefaultR(foldableArray)(dictMonoid);
}, $foreign.foldlArray, $foreign.foldrArray);
var foldMap = function (dict) {
return dict.foldMap;
};
var find = function (dictFoldable) {
return function (p) {
return foldl(dictFoldable)(function (r) {
return function (x) {
var $160 = p(x);
if ($160) {
return new Data_Maybe.Just(x);
};
if (!$160) {
return r;
};
throw new Error("Failed pattern match at Data.Foldable line 234, column 25 - line 234, column 50: " + [ $160.constructor.name ]);
};
})(Data_Maybe.Nothing.value);
};
};
exports["Foldable"] = Foldable;
exports["find"] = find;
exports["for_"] = for_;
exports["traverse_"] = traverse_;
exports["foldMapDefaultR"] = foldMapDefaultR;
exports["foldMap"] = foldMap;
exports["foldl"] = foldl;
exports["foldr"] = foldr;
exports["foldableArray"] = foldableArray;
exports["foldableMaybe"] = foldableMaybe;
})(PS["Data.Foldable"] = PS["Data.Foldable"] || {});
(function(exports) {
/* global exports */
"use strict";
// module Data.Traversable
// jshint maxparams: 3
exports.traverseArrayImpl = function () {
function Cont (fn) {
this.fn = fn;
}
var emptyList = {};
var ConsCell = function (head, tail) {
this.head = head;
this.tail = tail;
};
function consList (x) {
return function (xs) {
return new ConsCell(x, xs);
};
}
function listToArray (list) {
var arr = [];
while (list !== emptyList) {
arr.push(list.head);
list = list.tail;
}
return arr;
}
return function (apply) {
return function (map) {
return function (pure) {
return function (f) {
var buildFrom = function (x, ys) {
return apply(map(consList)(f(x)))(ys);
};
var go = function (acc, currentLen, xs) {
if (currentLen === 0) {
return acc;
} else {
var last = xs[currentLen - 1];
return new Cont(function () {
return go(buildFrom(last, acc), currentLen - 1, xs);
});
}
};
return function (array) {
var result = go(pure(emptyList), array.length, array);
while (result instanceof Cont) {
result = result.fn();
}
return map(listToArray)(result);
};
};
};
};
};
}();
})(PS["Data.Traversable"] = PS["Data.Traversable"] || {});
(function(exports) {
// Generated by psc version 0.8.5.0
"use strict";
var $foreign = PS["Data.Traversable"];
var Prelude = PS["Prelude"];
var Data_Foldable = PS["Data.Foldable"];
var Data_Maybe = PS["Data.Maybe"];
var Data_Maybe_First = PS["Data.Maybe.First"];
var Data_Maybe_Last = PS["Data.Maybe.Last"];
var Data_Monoid_Additive = PS["Data.Monoid.Additive"];
var Data_Monoid_Conj = PS["Data.Monoid.Conj"];
var Data_Monoid_Disj = PS["Data.Monoid.Disj"];
var Data_Monoid_Dual = PS["Data.Monoid.Dual"];
var Data_Monoid_Multiplicative = PS["Data.Monoid.Multiplicative"];
var Traversable = function (__superclass_Data$dotFoldable$dotFoldable_1, __superclass_Prelude$dotFunctor_0, sequence, traverse) {
this["__superclass_Data.Foldable.Foldable_1"] = __superclass_Data$dotFoldable$dotFoldable_1;
this["__superclass_Prelude.Functor_0"] = __superclass_Prelude$dotFunctor_0;
this.sequence = sequence;
this.traverse = traverse;
};
var traverse = function (dict) {
return dict.traverse;
};
var sequenceDefault = function (dictTraversable) {
return function (dictApplicative) {
return function (tma) {
return traverse(dictTraversable)(dictApplicative)(Prelude.id(Prelude.categoryFn))(tma);
};
};
};
var traversableArray = new Traversable(function () {
return Data_Foldable.foldableArray;
}, function () {
return Prelude.functorArray;
}, function (dictApplicative) {
return sequenceDefault(traversableArray)(dictApplicative);
}, function (dictApplicative) {
return $foreign.traverseArrayImpl(Prelude.apply(dictApplicative["__superclass_Prelude.Apply_0"]()))(Prelude.map((dictApplicative["__superclass_Prelude.Apply_0"]())["__superclass_Prelude.Functor_0"]()))(Prelude.pure(dictApplicative));
});
var sequence = function (dict) {
return dict.sequence;
};
var $$for = function (dictApplicative) {
return function (dictTraversable) {
return function (x) {
return function (f) {
return traverse(dictTraversable)(dictApplicative)(f)(x);
};
};
};
};
exports["Traversable"] = Traversable;
exports["for"] = $$for;
exports["sequenceDefault"] = sequenceDefault;
exports["sequence"] = sequence;
exports["traverse"] = traverse;
exports["traversableArray"] = traversableArray;
})(PS["Data.Traversable"] = PS["Data.Traversable"] || {});
(function(exports) {
// Generated by psc version 0.8.5.0
"use strict";
var Prelude = PS["Prelude"];
var Control_Alt = PS["Control.Alt"];
var Control_Extend = PS["Control.Extend"];
var Data_Bifoldable = PS["Data.Bifoldable"];
var Data_Bifunctor = PS["Data.Bifunctor"];
var Data_Bitraversable = PS["Data.Bitraversable"];
var Data_Foldable = PS["Data.Foldable"];
var Data_Monoid = PS["Data.Monoid"];
var Data_Traversable = PS["Data.Traversable"];
var Left = (function () {
function Left(value0) {
this.value0 = value0;
};
Left.create = function (value0) {
return new Left(value0);
};
return Left;
})();
var Right = (function () {
function Right(value0) {
this.value0 = value0;
};
Right.create = function (value0) {
return new Right(value0);
};
return Right;
})();
var functorEither = new Prelude.Functor(function (v) {
return function (v1) {
if (v1 instanceof Left) {
return new Left(v1.value0);
};
if (v1 instanceof Right) {
return new Right(v(v1.value0));
};
throw new Error("Failed pattern match at Data.Either line 53, column 3 - line 54, column 3: " + [ v.constructor.name, v1.constructor.name ]);
};
});
var foldableEither = new Data_Foldable.Foldable(function (dictMonoid) {
return function (f) {
return function (v) {
if (v instanceof Left) {
return Data_Monoid.mempty(dictMonoid);
};
if (v instanceof Right) {
return f(v.value0);
};
throw new Error("Failed pattern match at Data.Either line 206, column 3 - line 207, column 3: " + [ f.constructor.name, v.constructor.name ]);
};
};
}, function (v) {
return function (z) {
return function (v1) {
if (v1 instanceof Left) {
return z;
};
if (v1 instanceof Right) {
return v(z)(v1.value0);
};
throw new Error("Failed pattern match at Data.Either line 204, column 3 - line 205, column 3: " + [ v.constructor.name, z.constructor.name, v1.constructor.name ]);
};
};
}, function (v) {
return function (z) {
return function (v1) {
if (v1 instanceof Left) {
return z;
};
if (v1 instanceof Right) {
return v(v1.value0)(z);
};
throw new Error("Failed pattern match at Data.Either line 202, column 3 - line 203, column 3: " + [ v.constructor.name, z.constructor.name, v1.constructor.name ]);
};
};
});
var either = function (v) {
return function (v1) {
return function (v2) {
if (v2 instanceof Left) {
return v(v2.value0);
};
if (v2 instanceof Right) {
return v1(v2.value0);
};
throw new Error("Failed pattern match at Data.Either line 29, column 1 - line 30, column 1: " + [ v.constructor.name, v1.constructor.name, v2.constructor.name ]);
};
};
};
var applyEither = new Prelude.Apply(function () {
return functorEither;
}, function (v) {
return function (v1) {
if (v instanceof Left) {
return new Left(v.value0);
};
if (v instanceof Right) {
return Prelude["<$>"](functorEither)(v.value0)(v1);
};
throw new Error("Failed pattern match at Data.Either line 93, column 3 - line 94, column 3: " + [ v.constructor.name, v1.constructor.name ]);
};
});
var bindEither = new Prelude.Bind(function () {
return applyEither;
}, either(function (e) {
return function (v) {
return new Left(e);
};
})(function (a) {
return function (f) {
return f(a);
};
}));
var applicativeEither = new Prelude.Applicative(function () {
return applyEither;
}, Right.create);
var altEither = new Control_Alt.Alt(function () {
return functorEither;
}, function (v) {
return function (v1) {
if (v instanceof Left) {
return v1;
};
return v;
};