on master help sign in
Update changelog.txt and latest RTS
38e9b8devancz
elm/changelog.txt+8
@@ -4,6 +4,11 @@ Release 0.4.1
4
4
5* Add Automaton library.
5* Add Automaton library.
6
6
7+* Add Dict and Set libraries.
8+
9+* Remove the library prefixes `Data.` and `Signal.` because they were
10+ more confusing than helpful.
11+
7* Add (,,) notation for creating tuples.
12* Add (,,) notation for creating tuples.
8
13
9* Redo HTTP library, allowing any kind of request and more flexibility.
14* Redo HTTP library, allowing any kind of request and more flexibility.
@@ -11,6 +16,9 @@ Release 0.4.1
11* The Haskell API exports the absolute path to the Elm runtime
16* The Haskell API exports the absolute path to the Elm runtime
12 system (with the corresponding version number).
17 system (with the corresponding version number).
13
18
19+* Better type error reporting for ambiguous uses of variables and for aliased modules.
20+
21+* Add `readInt` and `readFloat` functions.
14* Fix bug in pattern parsing.
22* Fix bug in pattern parsing.
15* Ensure that `String` is treated as an alias of `[Char]`.
23* Ensure that `String` is treated as an alias of `[Char]`.
16* Make pattern matching a bit more concise.
24* Make pattern matching a bit more concise.
elm/elm-runtime-0.5.0.js+60−23
@@ -96,17 +96,29 @@ Elm.JSON = function() {
96 };
96 };
97 };
97 };
98 }
98 }
99+
99 function lookup(key) { return function(obj) {
100 function lookup(key) { return function(obj) {
100 var k = JS.castStringToJSString(key);
101 var k = JS.castStringToJSString(key);
101 return obj[1].hasOwnProperty(k) ? Just(obj[1][k]) : Nothing ;
102 return obj[1].hasOwnProperty(k) ? Just(obj[1][k]) : Nothing ;
102 };
103 };
103 }
104 }
105+ function find(tipe,base) { return function (key) { return function(obj) {
106+ var k = JS.castStringToJSString(key);
107+ if (obj[1].hasOwnProperty(k)) {
108+ var v = obj[1][k];
109+ if (v[0] === tipe) { return v[1]; }
110+ }
111+ return base;
112+ };
113+ }
114+ }
104 function lookupWithDefault(base) { return function(key) { return function(obj) {
115 function lookupWithDefault(base) { return function(key) { return function(obj) {
105 var k = JS.castStringToJSString(key);
116 var k = JS.castStringToJSString(key);
106 return obj[1].hasOwnProperty(k) ? obj[1][k] : base ;
117 return obj[1].hasOwnProperty(k) ? obj[1][k] : base ;
107 };
118 };
108 };
119 };
109 }
120 }
121+
110 function remove(k) { return function(inObj) {
122 function remove(k) { return function(inObj) {
111 var obj = inObj[1];
123 var obj = inObj[1];
112 var outObj = {};
124 var outObj = {};
@@ -192,6 +204,9 @@ Elm.JSON = function() {
192 singleton : singleton,
204 singleton : singleton,
193 insert : insert,
205 insert : insert,
194 lookup : lookup,
206 lookup : lookup,
207+ findString : find("JsonString",["Nil"]),
208+ findObject : find("JsonObject", empty ),
209+ findArray : find("JsonArray" ,["Nil"]),
195 findWithDefault : lookupWithDefault,
210 findWithDefault : lookupWithDefault,
196 remove : remove,
211 remove : remove,
197 toPrettyJSString : toPrettyJSString,
212 toPrettyJSString : toPrettyJSString,
@@ -264,7 +279,11 @@ var Value = function(){
264 arr[i] = spaces.join('');
279 arr[i] = spaces.join('');
265 }
280 }
266 }
281 }
267− return arr.join('');
282+ arr = arr.join('');
283+ if (arr[arr.length-1] === " ") {
284+ return arr.slice(0,-1) + ' ';
285+ }
286+ return arr;
268 }
287 }
269
288
270 function properEscape(str) {
289 function properEscape(str) {
@@ -400,7 +419,7 @@ var Value = function(){
400 } else if (v[0] === "Nil") {
419 } else if (v[0] === "Nil") {
401 return "[]";
420 return "[]";
402 } else if (v[0] === "JSON") {
421 } else if (v[0] === "JSON") {
403− return "(JSON.fromList " + toString(ElmJSON.toList(v)) + ")";
422+ return "(JSON.fromList " + toString(Elm.JSON.toList(v)) + ")";
404 } else if (v[0] === "RBNode" || v[0] === "RBEmpty") {
423 } else if (v[0] === "RBNode" || v[0] === "RBEmpty") {
405 function cons(k){ return function(v) { return function(acc) { return ["Cons",["Tuple2",k,v],acc]; }; }; }
424 function cons(k){ return function(v) { return function(acc) { return ["Cons",["Tuple2",k,v],acc]; }; }; }
406 return "(Map.fromList " + toString(Elm.Dict.fold(cons)(["Nil"])(v)) + ")";
425 return "(Map.fromList " + toString(Elm.Dict.fold(cons)(["Nil"])(v)) + ")";
@@ -1035,26 +1054,6 @@ Elm.Dict=function(){
1035 throw "Non-exhaustive pattern match in case";}();
1054 throw "Non-exhaustive pattern match in case";}();
1036 }
1055 }
1037 throw "Non-exhaustive pattern match in case";}();};};};
1056 throw "Non-exhaustive pattern match in case";}();};};};
1038− function find_9(k_60){
1039− return function(t_61){
1040− return function(){
1041− switch(t_61[0]){
1042− case "RBEmpty":
1043− return raise_5(Value.str("Key was not found in dictionary!"));
1044− case "RBNode":
1045− return function(){
1046− var case6=compare(k_60)(t_61[2]);
1047− switch(case6[0]){
1048− case "EQ":
1049− return t_61[3];
1050− case "GT":
1051− return find_9(k_60)(t_61[5]);
1052− case "LT":
1053− return find_9(k_60)(t_61[4]);
1054− }
1055− throw "Non-exhaustive pattern match in case";}();
1056− }
1057− throw "Non-exhaustive pattern match in case";}();};};
1058 function member_10(k_66){
1057 function member_10(k_66){
1059 return function(t_67){
1058 return function(t_67){
1060 return isJust(lookup_7(k_66)(t_67));};};
1059 return isJust(lookup_7(k_66)(t_67));};};
@@ -1456,7 +1455,7 @@ Elm.Dict=function(){
1456 return ["Cons",["Tuple2",k_232,v_233],acc_234];};};})(["Nil"])(t_231);};
1455 return ["Cons",["Tuple2",k_232,v_233],acc_234];};};})(["Nil"])(t_231);};
1457 function fromList_42(assocs_235){
1456 function fromList_42(assocs_235){
1458 return List.foldl(uncurry(insert_20))(empty_4)(assocs_235);};
1457 return List.foldl(uncurry(insert_20))(empty_4)(assocs_235);};
1459− return {empty:empty_4,lookup:lookup_7,findWithDefault:findWithDefault_8,find:find_9,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};}();
1458+ 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};}();
1460Elm.main=function(){
1459Elm.main=function(){
1461 return Elm.Dict.main;};
1460 return Elm.Dict.main;};
1462} catch (e) {Elm.main=function() {var msg = ('<br/><h2>Your browser may not be supported. Are you using a modern browser?</h2>' + '<br/><span style="color:grey">Runtime Error in Dict module:<br/>' + e + '</span>');document.body.innerHTML = Text.monospace(msg);throw e;};}
1461} catch (e) {Elm.main=function() {var msg = ('<br/><h2>Your browser may not be supported. Are you using a modern browser?</h2>' + '<br/><span style="color:grey">Runtime Error in Dict module:<br/>' + e + '</span>');document.body.innerHTML = Text.monospace(msg);throw e;};}
@@ -3379,6 +3378,42 @@ Elm.Prelude = function() {
3379 };
3378 };
3380
3379
3381 var logBase=function(b){return function(x){return Math.log(x)/Math.log(b);};};
3380 var logBase=function(b){return function(x){return Math.log(x)/Math.log(b);};};
3381+
3382+ function readInt(str) {
3383+ var s = JavaScript.castStringToJSString(str);
3384+ var len = s.length;
3385+ if (len === 0) { return Nothing; }
3386+ var start = 0;
3387+ if (s[0] == '-') {
3388+ if (len === 1) { return Nothing; }
3389+ start = 1;
3390+ }
3391+ for (var i = start; i < len; ++i) {
3392+ if (!Char.isDigit(s[i])) { return Nothing; }
3393+ }
3394+ return Just(parseInt(s));
3395+ }
3396+
3397+ function readFloat(str) {
3398+ var s = JavaScript.castStringToJSString(str);
3399+ var len = s.length;
3400+ if (len === 0) { return Nothing; }
3401+ var start = 0;
3402+ if (s[0] == '-') {
3403+ if (len === 1) { return Nothing; }
3404+ start = 1;
3405+ }
3406+ var dotCount = 0;
3407+ for (var i = start; i < len; ++i) {
3408+ if (Char.isDigit(s[i])) { continue; }
3409+ if (s[i] === '.') {
3410+ dotCount += 1;
3411+ if (dotCount <= 1) { continue; }
3412+ }
3413+ return Nothing;
3414+ }
3415+ return Just(parseFloat(s));
3416+ }
3382
3417
3383 return {eq : Value.eq,
3418 return {eq : Value.eq,
3384 id : function(x) { return x; },
3419 id : function(x) { return x; },
@@ -3398,6 +3433,8 @@ Elm.Prelude = function() {
3398 floor : function(n) { return Math.floor(n); },
3433 floor : function(n) { return Math.floor(n); },
3399 ceiling : function(n) { return Math.ceil(n); },
3434 ceiling : function(n) { return Math.ceil(n); },
3400 truncate : function(n) { return ~~n; },
3435 truncate : function(n) { return ~~n; },
3436+ readInt : readInt,
3437+ readFloat : readFloat,
3401 sqrt : Math.sqrt,
3438 sqrt : Math.sqrt,
3402 abs : Math.abs,
3439 abs : Math.abs,
3403 pi : Math.PI,
3440 pi : Math.PI,