on master help sign in
Add built-in event handlers (elm_log, elm_title, elm_redirect) and add Data.List.last
0934ab6evancz
core-js/Data.js+5−6
@@ -48,6 +48,7 @@ var Maybe = function() {
48 };
48 };
49}();
49}();
50
50
51+/*
51var String = function() {
52var String = function() {
52
53
53 function append(s1) { return function(s2) {
54 function append(s1) { return function(s2) {
@@ -119,16 +120,14 @@ var String = function() {
119 concatMap : concatMap,
120 concatMap : concatMap,
120 forall : forall,
121 forall : forall,
121 exists : exists,
122 exists : exists,
122− /*
123− filter : filter,
123+ //filter : filter,
124− take:,
124+ //take:,
125− drop:,
125+ //drop:,
126− */
127 toText : Value.toText,
126 toText : Value.toText,
128 properEscape : Value.properEscape
127 properEscape : Value.properEscape
129 };
128 };
130}();
129}();
131−
130+*/
132return {String: {toText:Value.toText, properEscape:Value.properEscape},
131return {String: {toText:Value.toText, properEscape:Value.properEscape},
133 Char:Char,
132 Char:Char,
134 Maybe:Maybe,
133 Maybe:Maybe,
core-js/Everything.js+6
@@ -1,6 +1,12 @@
1
1
2var eq = Value.eq;
2var eq = Value.eq;
3
3
4+Signal.addListener(document, 'elm_log', function(e) { console.log(e.value); });
5+Signal.addListener(document, 'elm_title', function(e) { document.title = e.value; });
6+Signal.addListener(document, 'elm_redirect', function(e) {
7+ if (e.value.length > 0) { window.location = e.value; }
8+ });
9+
4var includeGlobal = this;
10var includeGlobal = this;
5(function() {
11(function() {
6 var include = function(library) {
12 var include = function(library) {
core-js/List.js+12
@@ -56,6 +56,17 @@ var List = function() {
56 }
56 }
57 return v[2];
57 return v[2];
58 }
58 }
59+ function last(v) {
60+ if (v[0] !== "Cons") {
61+ throw "Error: 'last' only accepts lists of length greater than one.";
62+ }
63+ var out = v[1];
64+ while (v[0] === "Cons") {
65+ out = v[1];
66+ v = v[2];
67+ }
68+ return out;
69+ }
59 function map(f) {
70 function map(f) {
60 return function(xs) {
71 return function(xs) {
61 if (xs[0] === "Nil") { return xs; }
72 if (xs[0] === "Nil") { return xs; }
@@ -435,6 +446,7 @@ var List = function() {
435 }
446 }
436 return {head:head,
447 return {head:head,
437 tail:tail,
448 tail:tail,
449+ last:last,
438 map:map,
450 map:map,
439 foldl:foldl,
451 foldl:foldl,
440 foldr:foldr,
452 foldr:foldr,
core-js/Prelude.js+1
@@ -55,6 +55,7 @@ var Prelude = function() {
55 filter : Data.List.filter,
55 filter : Data.List.filter,
56 head : Data.List.head,
56 head : Data.List.head,
57 tail : Data.List.tail,
57 tail : Data.List.tail,
58+ last : Data.List.last,
58 length : Data.List.length,
59 length : Data.List.length,
59 reverse : Data.List.reverse,
60 reverse : Data.List.reverse,
60 foldr : Data.List.foldr,
61 foldr : Data.List.foldr,
core-js/runtime/Signal.js+2−1
@@ -284,7 +284,8 @@ var Signal = function() {
284 button:button};
284 button:button};
285 }();
285 }();
286
286
287+ return {addListener:addListener,
287− return {Mouse:Mouse,
288+ Mouse:Mouse,
288 Keyboard:Keyboard,
289 Keyboard:Keyboard,
289 Time:Time,
290 Time:Time,
290 Window:Window,
291 Window:Window,