on master help sign in
New way to import that does not clutter global namespace. Switch uses of `Nothing` and `Just` to simpler expressions.

Fix IE9 bug due to `console.log`.

commite85f31fda5c63047135b8a2573736c97bd2803c1 authorevancz <info@elm-lang.org> dateTue 20 Nov 2012, 23:18 (14 years ago) parent354c2ef
10 files changed+28−39
core-js/Automaton.js+2−8 core-js/Date.js+2−2 core-js/Dict.js+3−10 core-js/Graphics/Element.js+13−10 core-js/Graphics/Render.js+1−1 core-js/Prelude.js+2−2 core-js/Value.js+1−1 core-js/foreign/JSON.js+2−2 core-js/runtime/Dispatcher.js+1−2 core-js/runtime/Signal.js+1−1
core-js/Automaton.js+2−8
@@ -1,11 +1,6 @@
1−(function() {
2−
3−for(var i in Elm) { this[i] = Elm[i]; }
41Elm.Automaton=function(){
5− var hiddenVars=[];
6− for(var i in Elm.Prelude){
7− if (hiddenVars.indexOf(i) >= 0) continue;
8− this[i]=Elm.Prelude[i];}
2+ for(this['i'] in Elm.Prelude){
3+ eval('var ' + this['i'] + '=Elm.Prelude[this.i];'); }
94 function Automaton_0(a1){
105 return ["Automaton",a1];};
116 var Listen_9=["Listen"];
@@ -181,4 +176,3 @@ Elm.Automaton=function(){
181176 function draggable_14(form_93){
182177 return init__7(["Tuple2",Listen_9,form_93])(stepDrag_13);};
183178 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() {
33
44 function readDate(str) {
55 var d = new Date(Elm.JavaScript.castStringToJSString(str));
6− if (isNaN(d.getTime())) return Nothing;
7− return Just(d);
6+ if (isNaN(d.getTime())) return ["Nothing"];
7+ return ["Just",d];
88 }
99
1010 var dayTable = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
core-js/Dict.js+3−10
@@ -1,13 +1,7 @@
11
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.";
62Elm.Dict=function(){
7− var hiddenVars=[];
8− for(var i in Elm.Prelude){
9− if (hiddenVars.indexOf(i) >= 0) continue;
10− this[i]=Elm.Prelude[i];}
3+ for(this['i'] in Elm.Prelude){
4+ eval('var ' + this['i'] + '=Elm.Prelude[this.i];'); }
115 var isJust=Elm.Maybe.isJust;
126 var Red_0=["Red"];
137 var Black_1=["Black"];
@@ -19,7 +13,7 @@ Elm.Dict=function(){
1913 return ["RBNode",a1,a2,a3,a4,a5];};};};};};
2014 var RBEmpty_3=["RBEmpty"];
2115 var empty_4=RBEmpty_3;
22− var raise_5=console.log;
16+ var raise_5=function(x){return x;};
2317 function min_6(t_43){
2418 return function(){
2519 switch(t_43[0]){
@@ -476,4 +470,3 @@ Elm.Dict=function(){
476470 function fromList_42(assocs_235){
477471 return List.foldl(uncurry(insert_20))(empty_4)(assocs_235);};
478472 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 @@
11Elm.Graphics = function() {
2+ for (this['i'] in Elm.List) {
3+ eval('var ' + this['i'] + ' = Elm.List[this.i];');
4+ }
25 var JS = Elm.JavaScript;
36 var DLeft_0 = ["DLeft"];
47 var DRight_1 = ["DRight"];
@@ -156,7 +159,7 @@ Elm.Graphics = function() {
156159 var absolute_35 = Absolute_12;
157160 var relative_36 = Relative_13;
158161 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"]); }
160163 var line_76 = Line_75;
161164 var polygon_79 = Shape_78;
162165 function sprite_96(src) {
@@ -212,12 +215,12 @@ Elm.Graphics = function() {
212215 }
213216 function color_51(c) {
214217 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]);
216219 }
217220 }
218221 function link(lnk) {
219222 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)]);
221224 }
222225 }
223226 function widthOf_52(e) { return ~~e[3]; }
@@ -233,7 +236,7 @@ Elm.Graphics = function() {
233236 return basicNewElement(EText_39("left")(txt),p[0],p[1])
234237 }
235238 function asText(v) {
236− var txt = monospace(Value.toText(Value.show(v)));
239+ var txt = Elm.Text.monospace(Value.toText(Value.show(v)));
237240 var p = Value.getTextSize(0,0,txt);
238241 return basicNewElement(EText_39("left")(txt),p[0],p[1])
239242 }
@@ -320,17 +323,17 @@ Elm.Graphics = function() {
320323 }
321324 function above_61(e1_156) {
322325 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));
324327 }
325328 }
326329 function below_62(e1_158) {
327330 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));
329332 }
330333 }
331334 function beside_63(e1_160) {
332335 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)));
334337 }
335338 }
336339 function layers_64(es_162) {
@@ -379,7 +382,7 @@ Elm.Graphics = function() {
379382 var n_180 = 50;
380383 return function() {
381384 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)];
383386 }
384387 return Shape_78(map(f_181)(function() {
385388 var lo = 0;
@@ -404,10 +407,10 @@ Elm.Graphics = function() {
404407 return function(r_185) {
405408 return function(pos_186) {
406409 return function() {
407− var m_187 = toFloat(n_184);
410+ var m_187 = n_184;
408411 return function() {
409412 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)];
411414 }
412415 return Shape_78(map(f_188)(function() {
413416 var lo = 0;
core-js/Graphics/Render.js+1−1
@@ -225,7 +225,7 @@ function update(node,curr,next) {
225225 return node.parentNode.replaceChild(render(next),node);
226226 }
227227 var currs = currE[2];
228− var goDir = {};
228+ var goDir = function(x) { return x; };
229229 switch(nextE[1][0]) {
230230 case "DDown": case "DUp": goDir = goDown; break;
231231 case "DRight": case "DLeft": goDir = goRight; break;
core-js/Prelude.js+2−2
@@ -44,7 +44,7 @@ Elm.Prelude = function() {
4444 for (var i = start; i < len; ++i) {
4545 if (!Char.isDigit(s[i])) { return Nothing; }
4646 }
47− return Just(parseInt(s));
47+ return ["Just", parseInt(s)];
4848 }
4949
5050 function readFloat(str) {
@@ -65,7 +65,7 @@ Elm.Prelude = function() {
6565 }
6666 return Nothing;
6767 }
68− return Just(parseFloat(s));
68+ return ["Just", parseFloat(s)];
6969 }
7070
7171 return {eq : Value.eq,
core-js/Value.js+1−1
@@ -237,7 +237,7 @@ var Value = function(){
237237 function wrap(elem) {
238238 var p = Value.getSize(elem);
239239 return ["Element", Guid.guid(), ["EHtml",elem],
240− p[0], p[1], 1, Nothing, Nothing];
240+ p[0], p[1], 1, ["Nothing"], ["Nothing"]];
241241 }
242242 var addListener = function() {
243243 if(document.addEventListener) {
core-js/foreign/JSON.js+2−2
@@ -1,5 +1,5 @@
11
2−var JSjson = JSON;
2+var JSjson = window.JSON;
33Elm.JSON = function() {
44 var JS = Elm.JavaScript;
55 var empty = ['JSON',{}];
@@ -23,7 +23,7 @@ Elm.JSON = function() {
2323
2424 function lookup(key) { return function(obj) {
2525 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"] ;
2727 };
2828 }
2929 function find(tipe,base) { return function (key) { return function(obj) {
core-js/runtime/Dispatcher.js+1−2
@@ -18,7 +18,7 @@ var Dispatcher = function() {
1818 content.appendChild(Render.render(currentElement));
1919 var w = document.getElementById('widthChecker').offsetWidth;
2020 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));
2222 }
2323 program = Elm.Signal.lift(function(value) {
2424 var content = document.getElementById('content');
@@ -29,7 +29,6 @@ var Dispatcher = function() {
2929 };
3030 var notify = function(id, v) {
3131 timestep += 1;
32− //console.log(timestep);
3332 var hasListener = false;
3433 for (var i = inputs.length; i--; ) {
3534 hasListener = inputs[i].recv(timestep, id, v) || hasListener;
core-js/runtime/Signal.js+1−1
@@ -93,7 +93,7 @@ Elm.Signal = function() {
9393 this.value = input.value;
9494 this.kids = [];
9595 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);
9797 if (chng) { this.value = input.value; }
9898 send(this, timestep, chng);
9999 };