@@ -1,2102 +0,0 @@
2−var Guid = function() {
4− var guid = function() { counter += 1; return counter; };
7−var Foreign = function() {
8− var JavaScript = function() {
9− function castJSBoolToBool(b) { return b; }
10− function castBoolToJSBool(b) { return b; }
12− function castJSNumberToFloat(n) { return n; }
13− function castFloatToJSNumber(n) { return n; }
15− function castJSNumberToInt(n) { return ~~n; }
16− function castIntToJSNumber(n) { return n; }
18− function castJSElementToElement(w) { return Element.jsElement(w); }
19− function castElementToJSElement(elem) { return elem; }
21− function castJSArrayToList(arr) {
23− for (var i = arr.length; i--; ) {
24− list = [ "Cons", arr[i], list ];
28− function castListToJSArray(list) {
30− while (list[0] === "Cons") {
37− var castJSStringToString = castJSArrayToList;
38− function castStringToJSString(str) {
39− if (typeof str === "string") return str;
40− return castListToJSArray(str).join('');
43− function fromTuple(t) { return t.slice(1); }
44− function toTuple(a) { return a.unshift("Tuple" + a.length); }
46− return {castJSBoolToBool:castJSBoolToBool,
47− castBoolToJSBool:castBoolToJSBool,
48− castJSNumberToFloat:castJSNumberToFloat,
49− castFloatToJSNumber:castFloatToJSNumber,
50− castJSNumberToInt:castJSNumberToInt,
51− castIntToJSNumber:castIntToJSNumber,
52− Experimental : {castJSElementToElement:castJSElementToElement,
53− castElementToJSElement:castElementToJSElement},
54− castJSArrayToList:castJSArrayToList,
55− castListToJSArray:castListToJSArray,
56− castJSStringToString:castJSStringToString,
57− castStringToJSString:castStringToJSString,
58− castTupleToJSTuple2:fromTuple,
59− castTupleToJSTuple3:fromTuple,
60− castTupleToJSTuple4:fromTuple,
61− castTupleToJSTuple5:fromTuple,
62− castJSTupleToTuple2:toTuple,
63− castJSTupleToTuple3:toTuple,
64− castJSTupleToTuple4:toTuple,
65− castJSTupleToTuple5:toTuple
68− return {JavaScript:JavaScript};
70−var Value = function(){
72− var eq = function(x,y) {
73− if (typeof x === "object") {
74− if (x === y) return true;
75− if (x.length !== y.length) return false;
76− for (var i = x.length; i--; ) {
77− if (!eq(x[i],y[i])) return false;
84− var Tuple = function() {
85− var len = arguments.length;
86− var arr = new Array(len+1);
87− arr[0] = "Tuple" + arguments.length;
88− for (var i = len; i--; ) {
89− arr[i+1] = arguments[i];
94− var listToArray = function(list) {
96− while (list[0] === "Cons") {
103− var properEscape = function(str) {
104− str.replace('"', """);
105− str.replace("&", "&");
106− str.replace("'", "'");
107− str.replace("<", "<");
108− str.replace(">", ">");
112− var toText = function(elmList) {
113− if (typeof elmList === "string") return elmList;
115− while (elmList[0] === "Cons") {
117− elmList = elmList[2];
119− return properEscape(a.join(''));
122− var toString = function(v) {
123− if (typeof v === "boolean") {
124− return v ? "True" : "False";
125− } else if (typeof v === "number") {
128− if (v[0].substring(0,5) === "Tuple") {
130− for (var i = v.length; --i; ) {
131− output = "," + toString(v[i]) + output;
133− if (output[0] === ",") output = output.substring(1);
134− return "("+output+")";
135− } else if (v[0] === "Cons") {
136− var start = (typeof v[1] === "string") ? '"' : "[";
137− var end = (typeof v[1] === "string") ? '"' : "]";
138− var div = (typeof v[1] === "string") ? "" : ",";
139− var output = start + toString(v[1]);
142− if (v[0] === "Cons") {
143− output += div + toString(v[1]);
146− return output + end;
149− } else if (v[0] === "Nil") {
153− for (var i = v.length; --i; ) {
154− output = " " + toString(v[i]) + output
156− output = v[0] + output;
157− return (v.length > 1) ? "(" + output + ")" : output;
162− var show = function(v) {
163− return Text.monospace(properEscape(toString(v)));
165− var append = function(xs,ys) {
166− if (typeof xs === "string" && typeof ys === "string") {
167− return xs.concat(ys);
169− if (xs[0] === "Nil") {
172− var root = ["Cons", xs[1], ["Nil"]];
175− while (xs[0]==="Cons") {
176− curr[2] = ["Cons", xs[1], ["Nil"]];
184− var str = function(s) {
186− for (var i = s.length; i--; ) {
187− out = ["Cons", s[i], out];
197− listToArray:listToArray,
199− properEscape : properEscape};
200−}();var List = function() {
202− var throwError = function(f) {
203− throw "Function '" + f + "' expecting a list!";
206− function length(xs) {
208− while (xs[0] === "Cons") {
214− var reverse = foldl(function(x_72) {
215− return function(y_73) {
216− return["Cons", x_72, y_73]
219− var concat = foldr(function(x_74) {
220− return function(y_75) {
221− return Value.append(x_74, y_75)
224− var and = foldl(function(x_77) {
225− return function(y_78) {
229− var or = foldl(function(x_79) {
230− return function(y_80) {
234− var sum = foldl(function(x_89) {
235− return function(y_90) {
239− var product = foldl(function(x_91) {
240− return function(y_92) {
244− var maximum = foldl1(function(x) { return function(y) { return Math.max(x,y) } });
245− var minimum = foldl1(function(x) { return function(y) { return Math.min(x,y) } });
247− if (v[0] !== "Cons") {
248− throw "Error: 'head' only accepts lists of length greater than one.";
253− if (v[0] !== "Cons") {
254− throw "Error: 'tail' only accepts lists of length greater than one.";
259− if (v[0] !== "Cons") {
260− throw "Error: 'last' only accepts lists of length greater than one.";
263− while (v[0] === "Cons") {
270− return function(xs) {
271− if (xs[0] === "Nil") { return xs; }
272− if (xs[0] !== "Cons") { throwError('map'); }
273− var root = ["Cons", f(xs[1]), ["Nil"]];
276− while (xs[0]==="Cons") {
277− curr[2] = ["Cons", f(xs[1]), ["Nil"]];
285− return function(b) {
286− return function(xs) {
288− if (xs[0] === "Nil") { return acc; }
289− if (xs[0] !== "Cons") { throwError('foldl'); }
290− while (xs[0] === "Cons") {
291− acc = f(xs[1])(acc);
299− return function(b) {
300− return function(xs) {
302− if (xs[0] === "Nil") { return acc; }
303− if (xs[0] !== "Cons") { throwError('foldr'); }
305− while (xs[0] === "Cons") {
309− for (var i = arr.length; i--; ) {
310− acc = f(arr[i])(acc);
316− function foldl1(f_49) {
317− return function(_temp_50) {
318− return function(v) {
319− if("Cons" !== v[0]) {
324− return foldl(f_49)(x_51)(xs_52)
329− function foldr1(f) {
330− return function(xs) {
331− if (xs[0] === "Nil") { throw "'foldr1' requires an non-empty list." }
332− if (xs[0] !== "Cons") { throwError('foldr1'); }
334− while (xs[0] === "Cons") {
338− var acc = arr.pop();
339− for (var i = arr.length; i--; ) {
340− acc = f(arr[i])(acc);
346− return function(b) {
347− return function(xs) {
348− if (xs[0] === "Nil") { return ["Cons",b,["Nil"]]; }
349− if (xs[0] !== "Cons") { throwError('scanl'); }
351− while (xs[0] === "Cons") {
357− for (var i = arr.length; i--; ) {
358− out = ["Cons", arr[i], out];
364− function scanl1(f) {
365− return function(xs) {
366− if (xs[0] !== "Cons") {
367− throw "Error: 'scanl1' requires a list of at least length 1.";
369− return scanl(f)(xs[1])(xs[2]);
372− function filter(pred) {
373− return function(xs) {
374− if (xs[0] === "Nil") { return xs; }
375− if (xs[0] !== "Cons") { throwError('filter'); }
377− while (xs[0] === "Cons") {
378− if (pred(xs[1])) { arr.push(xs[1]); }
382− for (var i = arr.length; i--; ) {
383− out = ["Cons", arr[i], out];
388− function concatMap(f_76) {
389− return function(x) {
390− return concat(map(f_76)(x))
393− function forall(pred) {
394− return foldl(function(x) { return function(acc) {
395− return acc && pred(x);
398− function exists(pred) {
399− return foldl(function(x) { return function(acc) {
400− return acc || pred(x);
403− function partition(pred_93) {
404− return function(lst_94) {
407− var c = [function(v) {
408− if("Nil" !== v[0]) {
411− return["Tuple2", ["Nil"], ["Nil"]]
414− if("Cons" !== v[0]) {
419− return function(v) {
420− if("Tuple2" !== v[0]) {
425− return pred_93(x_95) ? ["Tuple2", ["Cons", x_95, as_97], bs_98] : ["Tuple2", as_97, ["Cons", x_95, bs_98]]
427− }(partition(pred_93)(xs_96))
430− for(var i = c.length;i--;) {
432− if(r !== undefined) {
439− function zipWith(f) {
440− return function(listA) {
441− return function(listB) {
442− if (listA[0] === "Nil" || listB[0] === "Nil") { return ["Nil"]; }
443− if (listA[0] !== "Cons" || listB[0] !== "Cons") { throwError('zipWith'); }
445− while (listA[0] === "Cons" && listB[0] === "Cons") {
446− arr.push(f(listA[1])(listB[1]));
451− for (var i = arr.length; i--; ) {
452− out = ["Cons", arr[i], out];
458− function zip(listA) {
459− return function(listB) {
460− if (listA[0] === "Nil" || listB[0] === "Nil") { return ["Nil"]; }
461− if (listA[0] !== "Cons" || listB[0] !== "Cons") { throwError('zip'); }
463− while (listA[0] === "Cons" && listB[0] === "Cons") {
464− arr.push(["Tuple2", listA[1], listB[1]]);
469− for (var i = arr.length; i--; ) {
470− out = ["Cons", arr[i], out];
475− function unzip(pairs_112) {
478− var c = [function(v) {
479− if("Nil" !== v[0]) {
482− return["Tuple2", ["Nil"], ["Nil"]]
485− if("Cons" !== v[0]) {
490− return function(v) {
491− if("Tuple2" !== v[0]) {
494− if("Tuple2" !== v[1][0]) {
497− var x_115 = v[1][1];
498− var y_116 = v[1][2];
499− if("Tuple2" !== v[2][0]) {
502− var xs_117 = v[2][1];
503− var ys_118 = v[2][2];
504− return["Tuple2", ["Cons", x_115, xs_117], ["Cons", y_116, ys_118]]
508− }(["Tuple2", p_113, unzip(ps_114)])
511− for(var i = c.length;i--;) {
513− if(r !== undefined) {
519− function intersperse(sep_119) {
520− return function(xs_120) {
523− var c = [function(v) {
524− if("Nil" !== v[0]) {
530− if("Cons" !== v[0]) {
534− if("Nil" !== v[2][0]) {
537− return["Cons", a_124, ["Nil"]]
541− if("Cons" !== v[0]) {
545− if("Cons" !== v[2][0]) {
548− var b_122 = v[2][1];
549− var cs_123 = v[2][2];
550− return["Cons", a_121, ["Cons", sep_119, intersperse(sep_119)(["Cons", b_122, cs_123])]]
554− for(var i = c.length;i--;) {
556− if(r !== undefined) {
563− function intercalate(sep_125) {
564− return function(xs_126) {
567− var c = [function(v) {
568− if("Nil" !== v[0]) {
574− if("Cons" !== v[0]) {
578− if("Nil" !== v[2][0]) {
585− if("Cons" !== v[0]) {
589− if("Cons" !== v[2][0]) {
592− var b_128 = v[2][1];
593− var cs_129 = v[2][2];
594− return Value.append(a_127, Value.append(sep_125, intercalate(sep_125)(["Cons", b_128, cs_129])))
598− for(var i = c.length;i--;) {
600− if(r !== undefined) {
608− if (xs[0] === "Nil") { return xs; }
609− if (xs[0] !== "Cons") { throwError('sort'); }
611− while (xs[0] === "Cons") {
615− arr.sort(function(a,b) { return a - b});
617− for (var i = arr.length; i--; ) {
618− out = [ "Cons", arr[i], out ];
622− function take(n) { return function(xs) {
623− if (n <= 0) { return ["Nil"]; }
624− if (xs[0] === "Nil") { return xs; }
625− if (xs[0] !== "Cons") { throwError('take'); }
626− var out = [ "Cons", xs[1], ["Nil"] ];
630− while (xs[0] === "Cons" && n > 0) {
631− temp[2] = [ "Cons", xs[1], ["Nil"] ];
639− function drop(n) { return function(xs) {
640− if (xs[0] === "Nil") { return xs; }
641− if (xs[0] !== "Cons") { throwError('drop'); }
642− while (xs[0] === "Cons" && n > 0) {
663− concatMap:concatMap,
672− partition:partition,
676− intersperse:intersperse,
677− intercalate:intercalate,
682−var Data = function() {
684−var Char = function() {
685− return {fromCode : function(c) { return String.fromCharCode(c); },
686− toCode : function(c) { return c.charCodeAt(0); },
687− toUpper : function(c) { return c.toUpperCase(); },
688− toLower : function(c) { return c.toLowerCase(); },
689− toLocaleUpper : function(c) { return c.toLocaleUpperCase(); },
690− toLocaleLower : function(c) { return c.toLocaleLowerCase(); }
694−var Maybe = function() {
695− function consMaybe(x) { return function(xs) {
696− if (x[0] === "Just") return ["Cons", x[1], xs];
700− function fromMaybe(b) { return function(m) {
701− if (m[0] === "Just") return m[1];
705− function mapCons(f) { return function(y) { return function(xs) {
707− if (x[0] === "Just") return ["Cons", x[1], xs];
712− function maybe(b) { return function(f) { return function(m) {
713− if (m[0] === "Just") return f(m[1]);
719− return {Just : function(x) { return ["Just",x]; },
720− Nothing : ["Nothing"],
721− catMaybes : List.foldr(consMaybe)(["Nil"]),
722− isJust : function(m) { return m[0] === "Just"; },
723− isNothing : function(m) { return m[0] === "Nothing"; },
724− fromMaybe : fromMaybe,
725− consMaybe : consMaybe,
726− mapMaybe : function(f) { return List.foldr(mapCons(f))(["Nil"]); },
732−var String = function() {
734− function append(s1) { return function(s2) {
735− return s1.concat(s2);
738− function map(f) { return function(s) {
739− for (var i = s.length; i--; ) { s[i] = f(s[i]); }
743− function intercalate(sep) { return function(ss) {
744− return Value.listToArray(ss).join(sep);
747− function intersperse(sep) { return function(s) {
748− return s.split("").join(sep);
752− function foldl(f) { return function(b) { return function(s) {
754− for (var i = 0, len = s.length; i < len; ++i) { acc = f(s[i])(acc); }
759− function foldr(f) { return function(b) { return function(s) {
761− for (var i = s.length; i--; ) { acc = f(s[i])(acc); }
767− function concatMap(f) { return function(s) {
768− var a = s.split("");
769− for (var i = a.length; i--; ) { a[i] = f(a[i]); }
774− function forall(pred) { return function(s) {
775− for (var i = s.length; i--; ) { if (!pred(s[i])) {return false}; }
779− function exists(pred) { return function(s) {
780− for (var i = s.length; i--; ) { if (pred(s[i])) {return true}; }
785− return {cons : append,
787− head : function(s) { return s[0]; },
788− last : function(s) { return s[s.length-1]; },
789− tail : function(s) { return s.slice(1); },
790− length : function(s) { return s.length; },
792− intercalate : intercalate,
793− intersperse : intersperse,
794− reverse : function(s) { return s.split("").reverse().join(""); },
795− toLower : function(s) { return s.toLowerCase(); },
796− toUpper : function(s) { return s.toUpperCase(); },
799− concat : function(ss) { return Value.listToArray(ss).join(""); },
800− concatMap : concatMap,
806− toText : Value.toText,
807− properEscape : Value.properEscape
811−return {String: {toText:Value.toText, properEscape:Value.properEscape},
817−var Color = function() {
819− var create = function(r,g,b,a) {
826− var extract = function(c) {
828− return 'rgb(' + c.r + ',' + c.g + ',' + c.b + ')';
830− return 'rgba(' + c.r + ',' + c.g + ',' + c.b + ',' + c.a + ')';
833− var rgba = function(r) { return function(g) { return function(b) {
834− return function(a) { return create(r,g,b,a); }; }; };
837− var rgb = function(r) { return function(g) { return function(b) {
838− return create(r,g,b,1); }; };
840− return {black: create( 0, 0, 0,1),
841− white: create(255,255,255,1),
842− red : create(255, 0, 0,1),
843− green: create( 0,255, 0,1),
844− blue : create( 0, 0,255,1),
846− gray : create(128,128,128,1),
847− grey : create(128,128,128,1),
849− yellow : create(255,255, 0,1),
850− cyan : create( 0,255,255,1),
851− magenta : create(255, 0,255,1),
855− Internal : { extract:extract }
858−var Element = function() {
859− var newElement = function(elementType) {
860− var e = document.createElement(elementType);
862− e.style.padding = "0";
863− e.style.margin = "0";
866− var addTo = function(container, elem) {
867− container.appendChild(clone(elem));
869− var clone = function(e) {
872− var divify = function(e) {
873− var div = newElement('div');
878− var rectangle = function(w) { return function(h) {
879− var e = newElement('div');
881− e.style.width = w + "px";
882− e.style.height = h + "px";
887− var makeText = function(w) { return function(pos) { return function(txt) {
888− var e = newElement('div');
892− e.style.textAlign = pos;
893− if (w > 0) e.style.width = w + "px";
898− var correctTextSize = function(e) {
899− var w = e.style.width ? e.style.width.slice(0,-2) : 0;
901− var t = newElement('div');
902− t.innerHTML = e.innerHTML;
903− t.style.textAlign = e.style.textAlign;
904− if (w > 0) { t.style.width = w + "px"; }
906− t.style.visibility = "hidden";
907− t.style.styleFloat = "left";
908− t.style.cssFloat = "left";
910− document.body.appendChild(t);
911− var cStyle = window.getComputedStyle(t);
912− if (w <= 0) e.style.width = cStyle.getPropertyValue("width");
913− e.style.height = cStyle.getPropertyValue("height");
914− document.body.removeChild(t);
917− var link = function (href) { return function (e) {
918− var a = newElement('a');
919− a.href = Text.fromString(href);
925− var text = makeText(0)('left');
926− var plainText = function(str) {
927− return makeText(0)("left")(Data.String.toText(str)); };
928− var justifiedText = makeText(0)('justify');
929− var centeredText = makeText(0)('center');
930− var rightedText = makeText(0)('right');
931− var asText = function(v) { return makeText(0)("left")(Value.show(v)); };
933− var image = function(src) {
934− var img = newElement('img');
935− img.isElmLeaf = true;
936− img.onload = function() {
937− if (img.style.width === "" && this.width > 0) {
938− img.style.width = img.width = this.width + "px";
940− if (img.style.height === "" && this.height > 0) {
941− img.style.height = img.height = this.height + "px";
945− img.src = Data.String.toText(src);
949− var fittedImage = function(w) { return function(h) { return function(src) {
950− var canvas = newElement('canvas');
951− canvas.style.width = w + 'px';
952− canvas.style.height = h + 'px';
955− canvas.innerHTML = "Your browser does not support the canvas element.";
956− canvas.isElmLeaf = true;
958− var img = newElement('img');
959− img.onload = function() {
960− if (canvas.getContext) {
961− var ctx = canvas.getContext('2d');
962− var sx = 0, sy = 0, sWidth = this.width, sHeight = this.height;
963− if (w / h > this.width / this.height) {
964− sHeight = this.width * h / w;
965− sy = (this.height - sHeight) / 2
967− sWidth = this.height * w / h;
968− sx = (this.width - sWidth) / 2
970− ctx.drawImage(img, sx, sy, sWidth, sHeight,
971− 0,0, canvas.width, canvas.height);
974− img.src = Data.String.toText(src);
980− var video = function(src) {
981− src = Data.String.toText(src);
982− var e = newElement('video');
983− e.controls = "controls";
984− var source = newElement('source');
986− source.type = "video/" + src.substring(src.length - 3, src.length);
991− var audio = function(src) {
992− src = Data.String.toString(src);
993− var e = newElement('video');
994− e.controls = "controls";
995− var source = newElement('source');
997− source.type = "audio/" + src.substring(src.length - 3, src.length);
1002− var collage = function(w) { return function(h) { return function(cflist) {
1003− var canvas = newElement('canvas');
1004− canvas.style.width = w + 'px';
1005− canvas.style.height = h + 'px';
1008− if (canvas.getContext) {
1009− var ctx = canvas.getContext('2d');
1010− ctx.clearRect(0,0, canvas.width, canvas.height);
1011− while (cflist[0] === "Cons") {
1012− ctx = cflist[1](ctx);
1013− cflist = cflist[2];
1017− canvas.innerHTML = "Your browser does not support the canvas element.";
1018− canvas.isElmLeaf = true;
1024− var goDown = function(e) {
1025− return e.tagName === "DIV" ? e : divify(e);
1027− var goRight = function(e) {
1028− e.style.styleFloat = "left";
1029− e.style.cssFloat = "left";
1032− var goIn = function(e) {
1033− e.style.position = 'absolute';
1036− var flowWith = function(dir, f, elist) {
1037− var container = newElement('div');
1038− for (var i = elist.length; i--; ) {
1039− addTo(container, f(elist[i]));
1041− container.elmFlowDirection = dir;
1045− var flow = function(direction) { return function(elist) {
1047− while (elist[0] === "Cons") {
1048− arr.push(elist[1]);
1051− if (direction >= 3) arr.reverse();
1052− var f = function(x) { return x; };
1053− var dir = direction % 3;
1054− if (dir == 0) return flowWith("Y", goDown , arr);
1055− if (dir == 1) return flowWith("X", goRight, arr);
1056− if (dir == 2) return flowWith("Z", goIn , arr);
1060− var beside = function(a) { return function(b) {
1061− return flow(4)(["Cons",a,["Cons",b,["Nil"]]]); }; };
1062− var above = function(a) { return function(b) {
1063− return flow(3)(["Cons",a,["Cons",b,["Nil"]]]); }; };
1064− var below = function(a) { return function(b) {
1065− return flow(0)(["Cons",a,["Cons",b,["Nil"]]]); }; };
1067− var box = function(pos) { return function(e) {
1068− e.style.position = "absolute";
1069− e.style.margin = "auto";
1070− var x = (pos - 1) % 3;
1071− var y = (pos - 1) / 3;
1072− if (x < 2) e.style.left = 0;
1073− if (x > 0) e.style.right = 0;
1074− if (y < 2) e.style.top = 0;
1075− if (y > 0) e.style.bottom = 0;
1076− var div = newElement('div');
1077− div.style.position = "relative";
1083− var width = function(w) { return function(e) {
1084− if (e.tagName === "A") {
1085− width(w)(e.firstChild);
1088− if (e.hasOwnProperty('isElmText')) {
1089− var d = makeText(w)(e.style.textAlign)(e.innerHTML);
1090− e.style.height = d.style.height;
1092− e.style.width = w + "px";
1096− var height = function(h) { return function(e) {
1097− (e.tagName === "A" ? e.firstChild : e).style.height = h + "px";
1101− var size = function(w) { return function(h) { return function(e) {
1102− var d = e.tagName === "A" ? e.firstChild : e;
1103− d.style.width = w + "px";
1104− d.style.height = h + "px";
1110− var color = function(c) { return function(e) {
1111− e.style.backgroundColor = Color.Internal.extract(c);
1115− var opacity = function(value) { return function(e) {
1116− e.style.opacity = value;
1121− var jsElement = function(w) { return function(h) { return function(elem) {
1122− var e = newElement('div');
1123− e.isElmLeaf = true;
1124− e.style.width = w + "px";
1125− e.style.height = h + "px";
1132− return {text : text,
1134− fittedImage : fittedImage,
1140− rectangle : rectangle,
1155− plainText : plainText,
1156− justifiedText : justifiedText,
1157− centeredText : centeredText,
1158− rightedText : rightedText,
1168− correctTextSize : correctTextSize,
1169− jsElement : jsElement
1175−var Text = function() {
1176− var fromString = function(elmList) {
1177− if (typeof elmList === "string") return elmList;
1179− while (elmList[0] === "Cons") {
1180− a.push(elmList[1]);
1181− elmList = elmList[2];
1183− return Data.String.properEscape(a.join(''));
1186− var addTag = function(tag) { return function(text) {
1187− return '<' + tag + ' style="padding:0;margin:0">' + text + '</' + tag + '>';
1190− var addStyle = function(style, value) { return function(text) {
1191− return "<span style='" + style + ":" + value + "'>" + text + "</span>";
1195− var typeface = function(name) { return addStyle('font-family', name); };
1196− var size = function(px) {
1197− return addStyle('font-size', px + 'px');
1199− var header = addTag('h1');
1200− var height = function(h) { return addStyle('font-size', h+'em'); }
1201− var italic = addStyle('font-style', 'italic');
1202− var bold = addTag('b');
1203− var color = function(c) {
1204− return addStyle('color', Color.Internal.extract(c));
1206− var underline = addStyle('text-decoration', 'underline');
1207− var overline = addStyle('text-decoration', 'overline');
1208− var strikeThrough = addStyle('text-decoration', 'line-through');
1209− var link = function(href) { return function(text) {
1210− return "<a href='" + fromString(href) + "'>" + text + "</a>";
1214− return {fromString : fromString,
1215− toText: fromString,
1220− underline : underline,
1221− overline : overline,
1222− strikeThrough : strikeThrough,
1223− monospace : typeface('monospace'),
1227−var Shape = function() {
1229− var create = function(center, ps, theta, s) {
1230− return { center: center, points: ps, theta: theta, scale: s };
1233− //// Construction ////
1235− var polygon = function(ps) { return function(center) {
1237− while (ps[0] === "Cons") {
1238− parr.push([ps[1][1], ps[1][2]]);
1241− center = [center[1], center[2]];
1242− return create(center, parr, 0, 1);
1245− var ngon = function(n) { return function(r) { return function(center) {
1247− for (var i = n; i--;) {
1248− ps.push([r * Math.cos(Math.PI * 2 * i/n),
1249− r * Math.sin(Math.PI * 2 * i/n)]);
1251− center = [center[1], center[2]];
1252− return create(center, ps, 0, 1);
1256− var rect = function(w) { return function(h) { return function(center) {
1257− var ps = [[- w/2, - h/2],
1261− center = [center[1], center[2]];
1262− return create(center, ps, 0, 1);
1266− var oval = function(w) { return function(h) { return function(center) {
1268− for (var theta = 2 * Math.PI; theta > 0; theta -= Math.PI /50) {
1269− ps.push([w/2 * Math.cos(theta), h/2 * Math.sin(theta)]);
1271− center = [center[1], center[2]];
1272− return create(center, ps, 0, 1);
1277−//// Transforms ////
1279− var move = function(x) { return function(y) { return function(shape) {
1280− var newCenter = [x + shape.center[0],y + shape.center[1]];
1281− return create(newCenter, shape.points, shape.theta, shape.scale);
1285− var rotate = function(theta) { return function(shape) {
1286− var newTheta = shape.theta + 2 * Math.PI * theta;
1287− return create(shape.center, shape.points, newTheta, shape.scale);
1290− var scale = function(s) { return function(shape) {
1291− return create(shape.center, shape.points, shape.theta, shape.scale * s);
1298− var draw = function(fill) {
1299− return function(color) { return function(shape) { return function(ctx) {
1301− ctx.translate(shape.center[0], shape.center[1]);
1302− ctx.rotate(shape.theta);
1303− ctx.scale(shape.scale, shape.scale);
1305− var points = shape.points;
1306− ctx.moveTo(points[0][0], points[0][1]);
1307− for (var i = points.length; i--; ) {
1308− ctx.lineTo(points[i][0], points[i][1]);
1312− ctx.fillStyle = Color.Internal.extract(color);
1315− ctx.strokeStyle = Color.Internal.extract(color);
1325− var customOutline = function(p) {
1326− return function(c) { return function(shape) {
1327− shape.points.push(shape.points[0]);
1328− return Line.customLine(p)(c)(shape);
1332− return {polygon:polygon, ngon:ngon, rect:rect, oval:oval,
1333− move:move, rotate:rotate, scale:scale,
1334− filled:draw(true), outlined:draw(false), customOutline:customOutline };
1336−var Line = function() {
1338− var pair = function(a,b) { return [a,b]; };
1340− var create = function(center, ps, theta, s) {
1341− return { center: center, points: ps, theta: theta, scale: s };
1345− //// Construction ////
1347− var line = function(ps) {
1349− while (ps[0] === "Cons") {
1350− parr.push(pair(ps[1][1], ps[1][2]));
1353− return create(pair(0,0), parr, 0, 1);
1358− var solid = function(color) { return function(line) { return function(ctx) {
1361− ctx.translate(line.center[0], line.center[1]);
1362− ctx.rotate(line.theta);
1363− ctx.scale(line.scale, line.scale);
1364− var points = line.points;
1365− var i = points.length;
1366− ctx.moveTo(points[i-1][0], points[i-1][1]);
1368− ctx.lineTo(points[i][0], points[i][1]);
1370− ctx.strokeStyle = Color.Internal.extract(color);
1378− var customLine = function(pattern) {
1379− return function(color) { return function(line) {
1380− if (typeof pattern[0] === "string") {
1382− while (pattern[0] === "Cons") {
1383− temp.push(pattern[1]);
1384− pattern = pattern[2];
1388− if (pattern.length === 0) { pattern = [8,4]; }
1389− return function(ctx) {
1392− ctx.translate(line.center[0], line.center[1]);
1393− ctx.rotate(line.theta);
1394− ctx.scale(line.scale, line.scale);
1395− customLineHelp(ctx, pattern, line.points);
1396− ctx.strokeStyle = Color.Internal.extract(color);
1404− var customLineHelp = function(ctx, pattern, points) {
1405− var i = points.length - 1;
1406− var x0 = points[i][0], y0 = points[i][1];
1407− var x1=0, y1=0, dx=0, dy=0, remaining=0, nx=0, ny=0;
1408− var pindex = 0, plen = pattern.length;
1409− var draw = true, segmentLength = pattern[0];
1412− x1 = points[i][0]; y1 = points[i][1];
1413− dx = x1 - x0; dy = y1 - y0;
1414− remaining = Math.sqrt(dx * dx + dy * dy);
1415− while (segmentLength <= remaining) {
1416− x0 += dx * segmentLength / remaining;
1417− y0 += dy * segmentLength / remaining;
1418− ctx[draw ? 'lineTo' : 'moveTo'](x0, y0);
1419− // update starting position
1420− dx = x1 - x0; dy = y1 - y0;
1421− remaining = Math.sqrt(dx * dx + dy * dy);
1424− pindex = (pindex + 1) % plen;
1425− segmentLength = pattern[pindex];
1427− if (remaining > 0) {
1428− ctx[draw ? 'lineTo' : 'moveTo'](x1, y1);
1429− segmentLength -= remaining;
1435− return {line:line, customLine:customLine, solid:solid,
1436− dashed: customLine([8,4]), dotted: customLine([3,3]) };
1439−var Elm = function() {
1440− var send = function(node, timestep, changed) {
1441− var kids = node.kids;
1442− for (var i = kids.length; i--; ) {
1443− kids[i].recv(timestep, changed, node.id);
1446− var input = function(base) {
1447− this.id = Guid.guid();
1450− this.recv = function(timestep, eid, v) {
1451− var changed = eid === this.id;
1452− if (changed) { this.value = v; }
1453− send(this, timestep, changed);
1455− Dispatcher.inputs.push(this);
1457− var lift = function(func,args) {
1458− this.id = Guid.guid();
1464− this.recalc = function() {
1466− for (var i = args.length; i--; ) {
1467− f = f(args[i].value);
1473− this.recv = function(timestep, changed, parentID) {
1474− if (!this.inbox.hasOwnProperty(timestep)) {
1475− this.inbox[timestep] = { changed: false, count: 0 };
1477− var box = this.inbox[timestep];
1479− if (changed) { box.changed = true; }
1480− if (box.count == args.length) {
1481− if (box.changed) { this.recalc() }
1482− send(this, timestep, box.changed);
1483− delete this.inbox[timestep];
1486− for (var i = args.length; i--; ) {
1487− args[i].kids.push(this);
1490− var fold = function(func,base,input) {
1491− this.id = Guid.guid();
1494− this.recv = function(timestep, changed, parentID) {
1495− if (changed) { this.value = func(input.value)(this.value); }
1496− send(this, timestep, changed);
1498− input.kids.push(this);
1501− var dropIf = function(pred,base,input) {
1502− this.id = Guid.guid();
1503− this.value = pred(input.value) ? base : input.value;
1505− this.recv = function(timestep, changed, parentID) {
1506− var chng = changed && !pred(input.value);
1507− if (chng) { this.value = input.value; }
1508− send(this, timestep, chng);
1510− input.kids.push(this);
1512− var dropRepeats = function(input) {
1513− this.id = Guid.guid();
1514− this.value = input.value;
1516− this.recv = function(timestep, changed, parentID) {
1517− var chng = changed && !eq(this.value,input.value);
1518− if (chng) { this.value = input.value; }
1519− send(this, timestep, chng);
1521− input.kids.push(this);
1524− var dropWhen = function(s1) { return function(b) { return function(s2) {
1525− var pairs = new lift(function(x){return function(y){return [x,y];};},[s1,s2]);
1526− var dropped = new dropIf(function(p){return p[0];},[true,b],pairs);
1527− return new lift(function(p){return p[1];},[dropped]); }; };
1530− var sampleOn = function(s1,s2) {
1531− this.id = Guid.guid();
1532− this.value = s2.value;
1536− this.recv = function(timestep, changed, parentID) {
1537− var chng = changed && parentID === s1.id;
1538− if (chng) { this.value = s2.value; }
1539− send(this, timestep, chng);
1541− s1.kids.push(this);
1542− s2.kids.push(this);
1545− return {Input: function(x) {return new input(x);},
1546− Lift: function(f,xs){return new lift(f,xs);},
1547− Fold: function(f,b,x){return new fold(f,b,x);},
1548− keepIf : function(pred) { return function(base) { return function(sig) {
1549− return new dropIf(function(x) { return !pred(x)},base,sig); }; }; },
1550− dropIf : function(pred) { return function(base) { return function(sig) {
1551− return new dropIf(pred,base,sig); }; }; },
1552− keepWhen : function(s) { return dropWhen(new lift(function(b){return !b;},[s])); },
1553− dropWhen : dropWhen,
1554− dropRepeats : function(s) { return new dropRepeats(s);},
1555− sampleOn : function(s1) { return function(s2) { return new sampleOn(s1,s2); }; }
1559−var Dispatcher = function() {
1560− var program = null;
1564− var correctSize = function(e) {
1565− var kids = e.childNodes;
1566− var len = kids.length;
1567− if (e.hasOwnProperty('isElmLeaf')) {
1568− if (e.hasOwnProperty('isElmText')) { Element.correctTextSize(e); }
1569− var w = e.style.width === "" ?
1570− 0 : e.style.width.slice(0,-2) - 0;
1571− var h = e.style.height === "" ?
1572− 0 : e.style.height.slice(0,-2) - 0;
1576− var dim = correctSize(kids[0]);
1577− if (e.style.width !== "") { dim[0] = e.style.width.slice(0,-2) - 0; }
1578− if (e.style.height !== "") { dim[1] = e.style.height.slice(0,-2) - 0; }
1579− if (dim[0] !== 0) { e.style.width = dim[0] + "px"; }
1580− if (dim[1] !== 0) { e.style.height = dim[1] + "px"; }
1583− var wmax = 0, hmax = 0, wsum = 0, hsum = 0;
1584− var hasWidth = true, hasHeight = true, dim = null;
1586− dim = correctSize(kids[len]);
1587− wmax = Math.max(wmax, dim[0]);
1588− hmax = Math.max(hmax, dim[1]);
1591− hasWidth = hasWidth && dim[0] > 0;
1592− hasHeight = hasHeight && dim[1] > 0;
1594− var w = wmax, h = hmax, dir = e.elmFlowDirection;
1595− if (dir === "X") { w = hasWidth ? wsum : 0; }
1596− if (dir === "Y") { h = hasHeight ? hsum : 0; }
1597− if (w > 0) e.style.width = w + "px";
1598− if (h > 0) e.style.height = h + "px";
1602− var initialize = function() {
1603− program = ElmCode.main();
1604− if (!program.hasOwnProperty('recv')) {
1605− program = Elm.Input(program);
1607− var content = document.getElementById('content');
1608− content.appendChild(program.value);
1610− var w = document.getElementById('widthChecker').offsetWidth;
1611− if (w !== window.innerWidth) {
1612− Dispatcher.notify(Window.dimensions.id, Value.Tuple(w, window.innerHeight));
1614− program = Elm.Lift(function(value) {
1615− var content = document.getElementById('content');
1616− var kid = content.children[0]
1617− content.replaceChild(value, kid);
1623− var adjust = function() {
1624− var content = document.getElementById('content');
1625− correctSize(content.children[0]);
1627− var notify = function(id, v) {
1629− for (var i = inputs.length; i--; ) {
1630− inputs[i].recv(timestep, id, v);
1633− return {initialize:initialize, notify:notify, adjust:adjust, inputs:inputs};
1635−var Signal = function() {
1636− function toElmString(str) {
1638− for (var i = str.length; i--; ) {
1639− out = ["Cons", str[i], out];
1643− var addListener = function() {
1644− if(document.addEventListener) {
1645− return function(element, event, handler) {
1646− element.addEventListener(event, handler, false);
1650− return function(element, event, handler) {
1651− element.attachEvent('on' + event, handler);
1656− var Mouse = function() {
1657− var position = Elm.Input(Value.Tuple(0,0));
1658− var isDown = Elm.Input(false);
1659− var isClicked = Elm.Input(false);
1660− var clicks = Elm.Input(Value.Tuple());
1662− function getXY(e) {
1665− if (!e) var e = window.event;
1666− if (e.pageX || e.pageY) {
1669− } else if (e.clientX || e.clientY) {
1670− posx = e.clientX + document.body.scrollLeft +
1671− document.documentElement.scrollLeft;
1672− posy = e.clientY + document.body.scrollTop +
1673− document.documentElement.scrollTop;
1675− return Value.Tuple(posx, posy);
1678− addListener(document, 'click', function(e) {
1679− Dispatcher.notify(isClicked.id, true);
1680− Dispatcher.notify(clicks.id, Value.Tuple());
1681− Dispatcher.notify(isClicked.id, false);
1683− addListener(document, 'mousedown', function(e) {
1684− Dispatcher.notify(isDown.id, true); });
1685− addListener(document, 'mouseup', function(e) {
1686− Dispatcher.notify(isDown.id, false); });
1687− addListener(document, 'mousemove', function(e) {
1688− Dispatcher.notify(position.id, getXY(e)); });
1689− var clickedOn = function(elem) {
1690− var click = Elm.Input(false);
1691− addListener(elem, 'click', function(e) {
1692− Dispatcher.notify(click.id, true);
1693− Dispatcher.notify(click.id, false);
1695− return Value.Tuple(elem, click);
1697− return {position: position,
1698− x: Elm.Lift(function(p){return p[1];},[position]),
1699− y: Elm.Lift(function(p){return p[2];},[position]),
1700− isClicked: isClicked,
1703− isClickedOn: clickedOn
1707− var Time = function() {
1708− var every = function(t) {
1710− var clock = Elm.Input(0);
1712− setInterval(function() {
1714− Dispatcher.notify(clock.id, time/1000);
1718− var after = function(t) {
1720− var thread = Elm.Input(false);
1721− setTimeout(function() { Dispatcher.notify(thread.id, true); }, t);
1724− var before = function(t) {
1726− var thread = Elm.Input(true);
1727− setTimeout(function() { Dispatcher.notify(thread.id, false); }, t);
1730− return {every:every,after:after,before:before};
1733− var Window = function() {
1734− var dimensions = Elm.Input(Value.Tuple(window.innerWidth,window.innerHeight));
1735− addListener(window, 'resize', function(e) {
1736− var w = document.getElementById('widthChecker').offsetWidth;
1737− Dispatcher.notify(dimensions.id, Value.Tuple(w, window.innerHeight));
1739− return {dimensions:dimensions,
1740− width : Elm.Lift(function(p){return p[1];},[dimensions]),
1741− height: Elm.Lift(function(p){return p[2];},[dimensions]) };
1744− var Keyboard = { Raw : function() {
1745− var keysDown = Elm.Input(["Nil"]);
1746− var charPressed = Elm.Input(["Nothing"]);
1747− function remove(x,xs) {
1748− if (xs[0] === "Nil") return xs;
1749− if (xs[1] === x) return xs[2];
1750− return ["Cons", xs[1], remove(x,xs[2])];
1752− function has(x,xs) {
1753− while (xs[0] !== "Nil") {
1754− if (xs[1] === x) return true;
1759− addListener(document, 'keydown', function(e) {
1760− if (has(e.keyCode, keysDown.value)) return;
1761− Dispatcher.notify(keysDown.id, ["Cons", e.keyCode, keysDown.value]);
1763− addListener(document, 'keyup', function(e) {
1764− var codes = remove(e.keyCode, keysDown.value)
1765− Dispatcher.notify(keysDown.id, codes);
1767− addListener(window, 'blur', function(e) {
1768− Dispatcher.notify(keysDown.id, ["Nil"]);
1770− addListener(document, 'keypress', function(e) {
1771− Dispatcher.notify(charPressed.id, ["Just",e.charCode || e.keyCode]);
1772− Dispatcher.notify(charPressed.id, ["Nothing"]);
1774− return {keysDown:keysDown,
1775− charPressed:charPressed};
1779− var HTTP = function() {
1780− var fetch = function(how) { return function(url) {
1781− var thread = Elm.Input(["Waiting"]);
1783− if (window.XMLHttpRequest) { request = new XMLHttpRequest(); }
1784− else if (window.ActiveXObject) { request = new ActiveXObject("Microsoft.XMLHTTP"); }
1785− request.onreadystatechange = function(e) {
1786− if (request.readyState === 4) {
1787− Dispatcher.notify(thread.id,
1788− request.status === 200
1789− ? ["Success", toElmString(request.responseText)]
1790− : ["Failure", request.status, toElmString(request.statusText)]);
1793− request.open(how, Data.String.toText(url), true);
1794− request.send(null);
1798− var fetches = function(how) { return function(input) {
1799− var output = Elm.Input(["Nothing"]);
1800− var fetcher = Elm.Lift(update, [input]);
1801− var combine = Elm.Lift(function(x) { return function(y) { return x; } }, [output,fetcher]);
1802− function update(strOpt) {
1803− if (strOpt[0] !== "Just") {
1804− try { Dispatcher.notify(output.id, ["Nothing"]); } catch(e) {}
1808− Dispatcher.notify(output.id, ["Just", ["Waiting"]]);
1809− } catch(e) { output.value = ["Just", ["Waiting"]]; }
1811− if (window.XMLHttpRequest) { request = new XMLHttpRequest(); }
1812− else if (window.ActiveXObject) { request = new ActiveXObject("Microsoft.XMLHTTP"); }
1813− request.onreadystatechange = function(e) {
1814− if (request.readyState === 4) {
1815− Dispatcher.notify(output.id,
1816− ["Just", request.status === 200
1817− ? ["Success", toElmString(request.responseText)]
1818− : ["Failure", request.status, toElmString(request.statusText)]]);
1821− request.open(how, Data.String.toText(strOpt[1]), true);
1822− request.send(null);
1828− return {get : fetch("GET"), post : fetch("POST"),
1829− gets : fetches("GET"), posts : fetches("POST")
1832− var Random = function() {
1833− var inRange = function(min) { return function(max) {
1834− return Elm.Input(Math.floor(Math.random() * (max-min+1)) + min);
1837− var randomize = function(min) { return function(max) { return function(signal) {
1838− return Elm.Lift(function(x) { return Math.floor(Math.random() * (max-min+1)) + min;},[signal]);
1842− return { inRange:inRange, randomize:randomize };
1844− var Input = function() {
1845− var newTextInput = function(elem, ghostText) {
1846− elem.isElmLeaf = true;
1847− var str = Elm.Input(["Nil"]);
1848− addListener(elem, 'keyup', function(e) {
1849− Dispatcher.notify(str.id, toElmString(elem.value));
1852− return Value.Tuple(elem, str);
1854− var newElement = function(name) {
1855− var e = document.createElement(name);
1856− e.id = Guid.guid();
1859− var textArea = function(cols) { return function(rows) {
1860− var textarea = newElement('textarea');
1861− textarea.rows = rows;
1862− textarea.cols = cols;
1863− return newTextInput(textarea, "");
1866− var textField = function(ghostText) {
1867− var field = newElement('input');
1868− field.type = 'text';
1869− return newTextInput(field, ghostText);
1871− var password = function(ghostText) {
1872− var field = newElement('input');
1873− field.type = 'password';
1874− return newTextInput(field, ghostText);
1876− var checkbox = function(checked) {
1877− var box = newElement('input');
1878− box.type = 'checkbox';
1879− box.checked = checked;
1880− var status = Elm.Input(checked);
1881− addListener(box, 'change', function(e) {
1882− Dispatcher.notify(status.id, box.checked);
1884− return Value.Tuple(box, status);
1886− var dropDown = function(options) {
1887− var slct = newElement('select');
1889− while (options[0] === "Cons") {
1890− var opt = newElement('option');
1891− var str = Text.toText(options[1][1]);
1893− opt.innerHTML = str;
1894− slct.appendChild(opt);
1895− opts.push(options[1][2]);
1896− options = options[2];
1898− var status = Elm.Input(opts[0]);
1899− addListener(slct, 'change', function(e) {
1900− Dispatcher.notify(status.id, opts[slct.selectedIndex]);
1902− return Value.Tuple(slct, status);
1904− var stringDropDown = function(opts) {
1905− return dropDown(List.map (function(x) {return Value.Tuple(x,x);}) (opts));
1907− var button = function(name) {
1908− var b = newElement('input');
1910− b.value = Text.toText(name);
1911− var press = Elm.Input(false);
1912− addListener(b, 'click', function(e) {
1913− Dispatcher.notify(press.id, true);
1914− Dispatcher.notify(press.id, false);
1916− return Value.Tuple(b,press);
1918− return {textArea:textArea, textField:textField,
1919− password:password, checkbox:checkbox,
1920− dropDown:dropDown, stringDropDown:stringDropDown,
1924− return {addListener:addListener,
1932− constant : function(v) { return Elm.Input(v); },
1933− lift : function(f){return function(e){return Elm.Lift(f,[e]);};},
1934− lift2 : function(f) { return function(e1) { return function(e2) {
1935− return Elm.Lift(f, [e1,e2]); }; }; },
1936− lift3 : function(f) { return function(e1) { return function(e2) {
1937− return function(e3){return Elm.Lift(f,[e1,e2,e3]);};};};},
1938− lift4 : function(f) { return function(e1) { return function(e2) {
1939− return function(e3) { return function(e4) {
1940− return Elm.Lift(f, [e1,e2,e3,e4]); }; }; }; }; },
1941− foldp : function(f) { return function(b) { return function(e) {
1942− return Elm.Fold(f,b,e); }; }; },
1943− count : function(sig){return Elm.Fold(function(_){return function(c){return c+1;};},0,sig)},
1944− keepIf : Elm.keepIf,
1945− dropIf : Elm.dropIf,
1946− keepWhen : Elm.keepWhen,
1947− dropWhen : Elm.dropWhen,
1948− dropRepeats : Elm.dropRepeats,
1949− sampleOn : Elm.sampleOn
1952−var Prelude = function() {
1953− var mod = function(x) { return function(y) {
1955− var m = x==0 ? 0 : (y>0 ? (x>=0 ? r : r+y) : -mod(-x)(-y));
1956− return m == y ? 0 : m;
1959− var min = function(x) { return function(y) { return Math.min(x,y); }; };
1960− var max = function(x) { return function(y) { return Math.max(x,y); }; };
1962− var flip=function(f){return function(x){return function(y){return f(y)(x);};};};
1963− var clamp = function(lo) { return function(hi) {
1964− return function(x) { return Math.min(hi, Math.max(lo, x)); };
1967− var curry = function(f) { return function(x) { return function(y) {
1968− return f(["Tuple2",x,y]); }; };
1970− var uncurry = function(f) { return function(p) {
1971− if (p[0] !== "Tuple2") {
1972− throw "Function was uncurry'd but was not given a pair.";
1974− return f(p[1])(p[2]); };
1977− var logBase=function(b){return function(x){return Math.log(x)/Math.log(b);};};
1979− return {id : function(x) { return x; },
1980− not : function(b) { return !b; },
1981− fst : function(p) { return p[1]; },
1982− snd : function(p) { return p[2]; },
1983− rem : function(x) { return function(y) { return x % y; }; },
2001− Just : Data.Maybe.Just,
2002− Nothing : Data.Maybe.Nothing,
2003− maybe : Data.Maybe.maybe,
2004− map : Data.List.map,
2005− filter : Data.List.filter,
2006− head : Data.List.head,
2007− tail : Data.List.tail,
2008− last : Data.List.last,
2009− length : Data.List.length,
2010− reverse : Data.List.reverse,
2011− foldr : Data.List.foldr,
2012− foldr1 : Data.List.foldr1,
2013− foldl : Data.List.foldl,
2014− foldl1 : Data.List.foldl1,
2015− and : Data.List.and,
2017− forall : Data.List.forall,
2018− exists : Data.List.exists,
2019− sum : Data.List.sum,
2020− product : Data.List.product,
2021− concat : Data.List.concat,
2022− concatMap : Data.List.concatMap,
2023− maximum : Data.List.maximum,
2024− minimum : Data.List.minimum,
2025− scanl : Data.List.scanl,
2026− scanl1 : Data.List.scanl1,
2027− take : Data.List.take,
2028− drop : Data.List.drop,
2029− lift : Signal.lift,
2030− lift2 : Signal.lift2,
2031− lift3 : Signal.lift3,
2032− lift4 : Signal.lift4,
2033− foldp : Signal.foldp,
2034− constant : Signal.constant,
2035− count : Signal.count,
2036− keepIf : Signal.keepIf,
2037− dropIf : Signal.dropIf,
2038− keepWhen : Signal.keepWhen,
2039− dropWhen : Signal.dropWhen,
2040− dropRepeats : Signal.dropRepeats,
2041− sampleOn : Signal.sampleOn
2046−Signal.addListener(document, 'elm_log', function(e) { console.log(e.value); });
2047−Signal.addListener(document, 'elm_title', function(e) { document.title = e.value; });
2048−Signal.addListener(document, 'elm_redirect', function(e) {
2049− if (e.value.length > 0) { window.location = e.value; }
2052−var includeGlobal = this;
2054− var include = function(library) {
2055− for (var i in library) {
2056− if (i === 'Internal') continue;
2058− includeGlobal[i] = library[i];
2060− if (i === 'length') {
2061− includeGlobal.execScript('var length;');
2062− length = library[i];
2068− var includeAs = function(name) { return function(library) {
2069− includeGlobal[name] = includeGlobal[name] || {};
2070− for (var i in library) {
2071− if (i === 'Internal') continue;
2072− includeGlobal[name][i] = library[i];
2079− color = Element.color;
2080− height = Element.height;
2087− includeAs ('Time') (Signal.Time);
2088− includeAs ('Mouse') (Signal.Mouse);
2089− includeAs ('Keyboard') (Signal.Keyboard);
2090− includeAs ('Window') (Signal.Window);
2091− includeAs ('HTTP') (Signal.HTTP);
2092− includeAs ('Input') (Signal.Input);
2093− includeAs ('Random') (Signal.Random);
2098−ElmCode.Data = Data;
2099−ElmCode.Signal = Signal;
2100−ElmCode.Data.List = List;
2101−ElmCode.Foreign = Foreign;
2102−ElmCode.Prelude = Prelude;