on master help sign in
New way to import that does not clutter global namespace. Switch uses of `Nothing` and `Just` to simpler expressions.
e85f31fevancz
core-js/Automaton.js+2−8
@@ -1,11 +1,6 @@
1−(function() {
2−
3−for(var i in Elm) { this[i] = Elm[i]; }
4Elm.Automaton=function(){
1Elm.Automaton=function(){
5− var hiddenVars=[];
6− for(var i in Elm.Prelude){
2+ for(this['i'] in Elm.Prelude){
7− if (hiddenVars.indexOf(i) >= 0) continue;
8− this[i]=Elm.Prelude[i];}
3+ eval('var ' + this['i'] + '=Elm.Prelude[this.i];'); }
9 function Automaton_0(a1){
4 function Automaton_0(a1){
10 return ["Automaton",a1];};
5 return ["Automaton",a1];};
11 var Listen_9=["Listen"];
6 var Listen_9=["Listen"];
@@ -181,4 +176,3 @@ Elm.Automaton=function(){
181 function draggable_14(form_93){
176 function draggable_14(form_93){
182 return init__7(["Tuple2",Listen_9,form_93])(stepDrag_13);};
177 return init__7(["Tuple2",Listen_9,form_93])(stepDrag_13);};
183 return {Automaton:Automaton_0,run:run_1,step:step_2,composeAuto:composeAuto_3,combine:combine_4,pure:pure_5,init:init_6,init_:init__7,count:count_8,Listen:Listen_9,Ignore:Ignore_10,DragFrom:DragFrom_11,vecSub:vecSub_12,stepDrag:stepDrag_13,draggable:draggable_14};}();
178 return {Automaton:Automaton_0,run:run_1,step:step_2,composeAuto:composeAuto_3,combine:combine_4,pure:pure_5,init:init_6,init_:init__7,count:count_8,Listen:Listen_9,Ignore:Ignore_10,DragFrom:DragFrom_11,vecSub:vecSub_12,stepDrag:stepDrag_13,draggable:draggable_14};}();
184−}());
core-js/Date.js+2−2
@@ -3,8 +3,8 @@ Elm.Date = function() {
3
3
4 function readDate(str) {
4 function readDate(str) {
5 var d = new Date(Elm.JavaScript.castStringToJSString(str));
5 var d = new Date(Elm.JavaScript.castStringToJSString(str));
6− if (isNaN(d.getTime())) return Nothing;
6+ if (isNaN(d.getTime())) return ["Nothing"];
7− return Just(d);
7+ return ["Just",d];
8 }
8 }
9
9
10 var dayTable = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
10 var dayTable = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
core-js/Dict.js+3−10
@@ -1,13 +1,7 @@
1
1
2−(function() {
3−
4−for(var i in Elm) { this[i] = Elm[i]; }
5−if (Elm.Dict) throw "Module name collision, 'Dict' is already defined.";
6Elm.Dict=function(){
2Elm.Dict=function(){
7− var hiddenVars=[];
8− for(var i in Elm.Prelude){
3+ for(this['i'] in Elm.Prelude){
9− if (hiddenVars.indexOf(i) >= 0) continue;
10− this[i]=Elm.Prelude[i];}
4+ eval('var ' + this['i'] + '=Elm.Prelude[this.i];'); }
11 var isJust=Elm.Maybe.isJust;
5 var isJust=Elm.Maybe.isJust;
12 var Red_0=["Red"];
6 var Red_0=["Red"];
13 var Black_1=["Black"];
7 var Black_1=["Black"];
@@ -19,7 +13,7 @@ Elm.Dict=function(){
19 return ["RBNode",a1,a2,a3,a4,a5];};};};};};
13 return ["RBNode",a1,a2,a3,a4,a5];};};};};};
20 var RBEmpty_3=["RBEmpty"];
14 var RBEmpty_3=["RBEmpty"];
21 var empty_4=RBEmpty_3;
15 var empty_4=RBEmpty_3;
22− var raise_5=console.log;
16+ var raise_5=function(x){return x;};
23 function min_6(t_43){
17 function min_6(t_43){
24 return function(){
18 return function(){
25 switch(t_43[0]){
19 switch(t_43[0]){
@@ -476,4 +470,3 @@ Elm.Dict=function(){
476 function fromList_42(assocs_235){
470 function fromList_42(assocs_235){
477 return List.foldl(uncurry(insert_20))(empty_4)(assocs_235);};
471 return List.foldl(uncurry(insert_20))(empty_4)(assocs_235);};
478 return {empty:empty_4,lookup:lookup_7,findWithDefault:findWithDefault_8,member:member_10,insert:insert_20,singleton:singleton_21,remove:remove_32,map:map_33,foldl:foldl_34,foldr:foldr_35,union:union_36,intersect:intersect_37,diff:diff_38,keys:keys_39,values:values_40,toList:toList_41,fromList:fromList_42};}();
472 return {empty:empty_4,lookup:lookup_7,findWithDefault:findWithDefault_8,member:member_10,insert:insert_20,singleton:singleton_21,remove:remove_32,map:map_33,foldl:foldl_34,foldr:foldr_35,union:union_36,intersect:intersect_37,diff:diff_38,keys:keys_39,values:values_40,toList:toList_41,fromList:fromList_42};}();
479−}());
core-js/Graphics/Element.js+13−10
@@ -1,4 +1,7 @@
1Elm.Graphics = function() {
1Elm.Graphics = function() {
2+ for (this['i'] in Elm.List) {
3+ eval('var ' + this['i'] + ' = Elm.List[this.i];');
4+ }
2 var JS = Elm.JavaScript;
5 var JS = Elm.JavaScript;
3 var DLeft_0 = ["DLeft"];
6 var DLeft_0 = ["DLeft"];
4 var DRight_1 = ["DRight"];
7 var DRight_1 = ["DRight"];
@@ -156,7 +159,7 @@ Elm.Graphics = function() {
156 var absolute_35 = Absolute_12;
159 var absolute_35 = Absolute_12;
157 var relative_36 = Relative_13;
160 var relative_36 = Relative_13;
158 function newElement_38(e,w,h,o,c,l) { return Element_37(Guid.guid(),e,w,h,o,c,l); }
161 function newElement_38(e,w,h,o,c,l) { return Element_37(Guid.guid(),e,w,h,o,c,l); }
159− function basicNewElement(e,w,h) { return Element_37(Guid.guid(),e,w,h,1,Nothing,Nothing); }
162+ function basicNewElement(e,w,h) { return Element_37(Guid.guid(),e,w,h,1,["Nothing"],["Nothing"]); }
160 var line_76 = Line_75;
163 var line_76 = Line_75;
161 var polygon_79 = Shape_78;
164 var polygon_79 = Shape_78;
162 function sprite_96(src) {
165 function sprite_96(src) {
@@ -212,12 +215,12 @@ Elm.Graphics = function() {
212 }
215 }
213 function color_51(c) {
216 function color_51(c) {
214 return function(e) {
217 return function(e) {
215− return newElement_38(e[2], e[3], e[4], e[5], Just(c), e[7]);
218+ return newElement_38(e[2], e[3], e[4], e[5], ["Just",c], e[7]);
216 }
219 }
217 }
220 }
218 function link(lnk) {
221 function link(lnk) {
219 return function(e) {
222 return function(e) {
220− return newElement_38(e[2], e[3], e[4], e[5], e[6], Just(JS.castStringToJSString(lnk)));
223+ return newElement_38(e[2], e[3], e[4], e[5], e[6], ["Just", JS.castStringToJSString(lnk)]);
221 }
224 }
222 }
225 }
223 function widthOf_52(e) { return ~~e[3]; }
226 function widthOf_52(e) { return ~~e[3]; }
@@ -233,7 +236,7 @@ Elm.Graphics = function() {
233 return basicNewElement(EText_39("left")(txt),p[0],p[1])
236 return basicNewElement(EText_39("left")(txt),p[0],p[1])
234 }
237 }
235 function asText(v) {
238 function asText(v) {
236− var txt = monospace(Value.toText(Value.show(v)));
239+ var txt = Elm.Text.monospace(Value.toText(Value.show(v)));
237 var p = Value.getTextSize(0,0,txt);
240 var p = Value.getTextSize(0,0,txt);
238 return basicNewElement(EText_39("left")(txt),p[0],p[1])
241 return basicNewElement(EText_39("left")(txt),p[0],p[1])
239 }
242 }
@@ -320,17 +323,17 @@ Elm.Graphics = function() {
320 }
323 }
321 function above_61(e1_156) {
324 function above_61(e1_156) {
322 return function(e2_157) {
325 return function(e2_157) {
323− return basicNewElement(EFlow_43(DDown_3)(["Cons", e1_156, ["Cons", e2_157, ["Nil"]]]), max(widthOf_52(e1_156))(widthOf_52(e2_157)), heightOf_53(e1_156) + heightOf_53(e2_157))
326+ return basicNewElement(EFlow_43(DDown_3)(["Cons", e1_156, ["Cons", e2_157, ["Nil"]]]), Math.max(widthOf_52(e1_156),widthOf_52(e2_157)), heightOf_53(e1_156) + heightOf_53(e2_157));
324 }
327 }
325 }
328 }
326 function below_62(e1_158) {
329 function below_62(e1_158) {
327 return function(e2_159) {
330 return function(e2_159) {
328− return basicNewElement(EFlow_43(DDown_3)(["Cons", e2_159, ["Cons", e1_158, ["Nil"]]]), max(widthOf_52(e1_158))(widthOf_52(e2_159)), heightOf_53(e1_158) + heightOf_53(e2_159))
331+ return basicNewElement(EFlow_43(DDown_3)(["Cons", e2_159, ["Cons", e1_158, ["Nil"]]]), Math.max(widthOf_52(e1_158),widthOf_52(e2_159)), heightOf_53(e1_158) + heightOf_53(e2_159));
329 }
332 }
330 }
333 }
331 function beside_63(e1_160) {
334 function beside_63(e1_160) {
332 return function(e2_161) {
335 return function(e2_161) {
333− return basicNewElement(EFlow_43(DRight_1)(["Cons", e1_160, ["Cons", e2_161, ["Nil"]]]), widthOf_52(e1_160) + widthOf_52(e2_161), max(heightOf_53(e1_160))(heightOf_53(e2_161)))
336+ return basicNewElement(EFlow_43(DRight_1)(["Cons", e1_160, ["Cons", e2_161, ["Nil"]]]), widthOf_52(e1_160) + widthOf_52(e2_161), Math.max(heightOf_53(e1_160),heightOf_53(e2_161)));
334 }
337 }
335 }
338 }
336 function layers_64(es_162) {
339 function layers_64(es_162) {
@@ -379,7 +382,7 @@ Elm.Graphics = function() {
379 var n_180 = 50;
382 var n_180 = 50;
380 return function() {
383 return function() {
381 function f_181(i_182) {
384 function f_181(i_182) {
382− return["Tuple2", w_177 / 2 * cos(2 * (pi / n_180) * i_182), h_178 / 2 * sin(2 * (pi / n_180) * i_182)]
385+ return["Tuple2", w_177 / 2 * Math.cos(2 * (Math.PI / n_180) * i_182), h_178 / 2 * Math.sin(2 * (Math.PI / n_180) * i_182)];
383 }
386 }
384 return Shape_78(map(f_181)(function() {
387 return Shape_78(map(f_181)(function() {
385 var lo = 0;
388 var lo = 0;
@@ -404,10 +407,10 @@ Elm.Graphics = function() {
404 return function(r_185) {
407 return function(r_185) {
405 return function(pos_186) {
408 return function(pos_186) {
406 return function() {
409 return function() {
407− var m_187 = toFloat(n_184);
410+ var m_187 = n_184;
408 return function() {
411 return function() {
409 function f_188(i_189) {
412 function f_188(i_189) {
410− return["Tuple2", r_185 * cos(2 * (pi / m_187) * i_189), r_185 * sin(2 * (pi / m_187) * i_189)]
413+ return["Tuple2", r_185 * Math.cos(2 * (Math.PI / m_187) * i_189), r_185 * Math.sin(2 * (Math.PI / m_187) * i_189)];
411 }
414 }
412 return Shape_78(map(f_188)(function() {
415 return Shape_78(map(f_188)(function() {
413 var lo = 0;
416 var lo = 0;
core-js/Graphics/Render.js+1−1
@@ -225,7 +225,7 @@ function update(node,curr,next) {
225 return node.parentNode.replaceChild(render(next),node);
225 return node.parentNode.replaceChild(render(next),node);
226 }
226 }
227 var currs = currE[2];
227 var currs = currE[2];
228− var goDir = {};
228+ var goDir = function(x) { return x; };
229 switch(nextE[1][0]) {
229 switch(nextE[1][0]) {
230 case "DDown": case "DUp": goDir = goDown; break;
230 case "DDown": case "DUp": goDir = goDown; break;
231 case "DRight": case "DLeft": goDir = goRight; break;
231 case "DRight": case "DLeft": goDir = goRight; break;
core-js/Prelude.js+2−2
@@ -44,7 +44,7 @@ Elm.Prelude = function() {
44 for (var i = start; i < len; ++i) {
44 for (var i = start; i < len; ++i) {
45 if (!Char.isDigit(s[i])) { return Nothing; }
45 if (!Char.isDigit(s[i])) { return Nothing; }
46 }
46 }
47− return Just(parseInt(s));
47+ return ["Just", parseInt(s)];
48 }
48 }
49
49
50 function readFloat(str) {
50 function readFloat(str) {
@@ -65,7 +65,7 @@ Elm.Prelude = function() {
65 }
65 }
66 return Nothing;
66 return Nothing;
67 }
67 }
68− return Just(parseFloat(s));
68+ return ["Just", parseFloat(s)];
69 }
69 }
70
70
71 return {eq : Value.eq,
71 return {eq : Value.eq,
core-js/Value.js+1−1
@@ -237,7 +237,7 @@ var Value = function(){
237 function wrap(elem) {
237 function wrap(elem) {
238 var p = Value.getSize(elem);
238 var p = Value.getSize(elem);
239 return ["Element", Guid.guid(), ["EHtml",elem],
239 return ["Element", Guid.guid(), ["EHtml",elem],
240− p[0], p[1], 1, Nothing, Nothing];
240+ p[0], p[1], 1, ["Nothing"], ["Nothing"]];
241 }
241 }
242 var addListener = function() {
242 var addListener = function() {
243 if(document.addEventListener) {
243 if(document.addEventListener) {
core-js/foreign/JSON.js+2−2
@@ -1,5 +1,5 @@
1
1
2−var JSjson = JSON;
2+var JSjson = window.JSON;
3Elm.JSON = function() {
3Elm.JSON = function() {
4 var JS = Elm.JavaScript;
4 var JS = Elm.JavaScript;
5 var empty = ['JSON',{}];
5 var empty = ['JSON',{}];
@@ -23,7 +23,7 @@ Elm.JSON = function() {
23
23
24 function lookup(key) { return function(obj) {
24 function lookup(key) { return function(obj) {
25 var k = JS.castStringToJSString(key);
25 var k = JS.castStringToJSString(key);
26− return obj[1].hasOwnProperty(k) ? Just(obj[1][k]) : Nothing ;
26+ return obj[1].hasOwnProperty(k) ? ["Just", obj[1][k]] : ["Nothing"] ;
27 };
27 };
28 }
28 }
29 function find(tipe,base) { return function (key) { return function(obj) {
29 function find(tipe,base) { return function (key) { return function(obj) {
core-js/runtime/Dispatcher.js+1−2
@@ -18,7 +18,7 @@ var Dispatcher = function() {
18 content.appendChild(Render.render(currentElement));
18 content.appendChild(Render.render(currentElement));
19 var w = document.getElementById('widthChecker').offsetWidth;
19 var w = document.getElementById('widthChecker').offsetWidth;
20 if (w !== window.innerWidth) {
20 if (w !== window.innerWidth) {
21− Dispatcher.notify(Window.dimensions.id, Value.Tuple(w, window.innerHeight));
21+ Dispatcher.notify(Elm.Window.dimensions.id, Value.Tuple(w, window.innerHeight));
22 }
22 }
23 program = Elm.Signal.lift(function(value) {
23 program = Elm.Signal.lift(function(value) {
24 var content = document.getElementById('content');
24 var content = document.getElementById('content');
@@ -29,7 +29,6 @@ var Dispatcher = function() {
29 };
29 };
30 var notify = function(id, v) {
30 var notify = function(id, v) {
31 timestep += 1;
31 timestep += 1;
32− //console.log(timestep);
33 var hasListener = false;
32 var hasListener = false;
34 for (var i = inputs.length; i--; ) {
33 for (var i = inputs.length; i--; ) {
35 hasListener = inputs[i].recv(timestep, id, v) || hasListener;
34 hasListener = inputs[i].recv(timestep, id, v) || hasListener;
core-js/runtime/Signal.js+1−1
@@ -93,7 +93,7 @@ Elm.Signal = function() {
93 this.value = input.value;
93 this.value = input.value;
94 this.kids = [];
94 this.kids = [];
95 this.recv = function(timestep, changed, parentID) {
95 this.recv = function(timestep, changed, parentID) {
96− var chng = changed && !eq(this.value,input.value);
96+ var chng = changed && !Value.eq(this.value,input.value);
97 if (chng) { this.value = input.value; }
97 if (chng) { this.value = input.value; }
98 send(this, timestep, chng);
98 send(this, timestep, chng);
99 };
99 };