@@ -444,9 +444,9 @@ var Value = function(){
445 return "(" + name + ".fromList " + toString(list) + ")";
445 return "(" + name + ".fromList " + toString(list) + ")";
447− var output = [];
447+ var output = "";
448− for (var i = v.length; --i; ) { output.push(toString(v[i])); }
448+ for (var i = v.length; --i; ) { output = ' ' + toString(v[i]) + output; }
449− output = v[0] + ' ' + output.join(' ');
449+ output = v[0] + output;
450 return (v.length > 1) ? "(" + output + ")" : output;
450 return (v.length > 1) ? "(" + output + ")" : output;
@@ -1000,11 +1000,6 @@ Elm.Maybe = function() {
1000 return xs;
1000 return xs;
1003− function fromMaybe(b) { return function(m) {
1004− if (m[0] === "Just") return m[1];
1008 function mapCons(f) { return function(y) { return function(xs) {
1003 function mapCons(f) { return function(y) { return function(xs) {
1009 var x = f(y);
1004 var x = f(y);
1010 if (x[0] === "Just") return ["Cons", x[1], xs];
1005 if (x[0] === "Just") return ["Cons", x[1], xs];
@@ -1021,16 +1016,45 @@ Elm.Maybe = function() {
1022 return {Just : function(x) { return ["Just",x]; },
1017 return {Just : function(x) { return ["Just",x]; },
1023 Nothing : ["Nothing"],
1018 Nothing : ["Nothing"],
1024− catMaybes : Elm.List.foldr(consMaybe)(["Nil"]),
1019+ justs : Elm.List.foldr(consMaybe)(["Nil"]),
1025 isJust : function(m) { return m[0] === "Just"; },
1020 isJust : function(m) { return m[0] === "Just"; },
1026 isNothing : function(m) { return m[0] === "Nothing"; },
1021 isNothing : function(m) { return m[0] === "Nothing"; },
1027− fromMaybe : fromMaybe,
1028− consMaybe : consMaybe,
1022+ cons : consMaybe,
1029− mapMaybe : function(f) { return Elm.List.foldr(mapCons(f))(["Nil"]); },
1030 maybe : maybe
1023 maybe : maybe
1027+Elm.Either = function() {
1028+ function Left(a1) { return ['Left',a1]; }
1029+ function Right(a1){ return ['Right',a1]; }
1030+ function either(f){ return function(g){ return function(e){
1032+ case 'Left': return f(e[1]);
1033+ case 'Right': return g(e[1]);
1036+ function isLeft(e) { return e[0] == 'Left'; }
1037+ function isRight(e) { return e[0] == 'Right'; }
1039+ function get(es) { return Elm.List.map(function(x){return x[1];})(es); }
1040+ function lefts(es) { return get(Elm.List.filter(isLeft)(es)); }
1041+ function rights(es) { return get(Elm.List.filter(isRight)(es)); }
1042+ function partition(es) {
1043+ var lrs = Elm.List.partition(isLeft)(es);
1044+ lrs[1] = get(lrs[1]);
1045+ lrs[2] = get(lrs[2]);
1055+ partition:partition};
1034Elm.Char = function() {
1058Elm.Char = function() {
1035 function isBetween(lo,hi) { return function(chr) {
1059 function isBetween(lo,hi) { return function(chr) {
1036 var c = chr.charCodeAt(0);
1060 var c = chr.charCodeAt(0);
@@ -2943,32 +2967,6 @@ Elm.Mouse = function() {
2943 isClickedOn: clickedOn
2967 isClickedOn: clickedOn
2946−Elm.Touch = function() {
2947− var touches = Elm.Signal.constant(["Nil"]);
2949− function touch(t) {
2950− return {_ : [true], x: [t.pageX], y: [t.pageY], id: [t.identifier] };
2953− function listen(name) {
2954− function update(e) {
2955− var ts = Elm.JavaScript.castJSArrayToList(e.touches);
2956− var hasListener = Dispatcher.notify(touches.id, Elm.List.map(touch)(ts));
2958− return this.removeEventListener(name,arguments.callee,false);
2959− e.preventDefault();
2961− Value.addListener(document, name, update);
2964− listen("touchstart");
2965− listen("touchmove");
2966− listen("touchend");
2967− listen("touchcancel");
2968− listen("touchleave");
2970− return { touches: touches };
2972Elm.Random = function() {
2970Elm.Random = function() {
2973 var inRange = function(min) { return function(max) {
2971 var inRange = function(min) { return function(max) {
2974 return Elm.Signal.constant(Math.floor(Math.random() * (max-min+1)) + min);
2972 return Elm.Signal.constant(Math.floor(Math.random() * (max-min+1)) + min);
@@ -3303,6 +3301,102 @@ Elm.Prelude = function() {
3304+Elm.Touch = function() {
3306+ function log(id,msg) {
3307+ var e = document.getElementById('logger' + id);
3309+ e = document.createElement('div');
3310+ e.id = 'logger' + id;
3311+ document.body.appendChild(e);
3320+ this.insert = function(key,value) {
3321+ this.keys.push(key);
3322+ this.values.push(value);
3324+ this.lookup = function(key) {
3325+ var i = this.keys.indexOf(key)
3326+ return i >= 0 ? this.values[i] : {x:0,y:0,t:0};
3328+ this.remove = function(key) {
3329+ var i = this.keys.indexOf(key);
3331+ var t = this.values[i];
3332+ this.keys.splice(i,1);
3333+ this.values.splice(i,1);
3338+ var root = Elm.Signal.constant([]),
3341+ tap = {_:[true],x:[0],y:[0]},
3344+ function touch(t) {
3345+ var r = dict.lookup(t.identifier);
3346+ return {_ : [true], id: [t.identifier],
3347+ x: [t.pageX], y: [t.pageY],
3348+ x0: [r.x], y0: [r.y],
3352+ function start(e) {
3353+ dict.insert(e.identifier,{x:e.pageX,y:e.pageY,t:Date.now()});
3356+ var t = dict.remove(e.identifier);
3357+ if (Date.now() - t.t < tapTime) {
3359+ tap = {_:[true], x:[t.x], y:[t.y]};
3363+ function listen(name, f) {
3364+ function update(e) {
3365+ for (var i = e.changedTouches.length; i--; ) { f(e.changedTouches[i]); }
3366+ var ts = new Array(e.touches.length);
3367+ for (var i = e.touches.length; i--; ) { ts[i] = touch(e.touches[i]); }
3368+ var hasListener = Dispatcher.notify(root.id, ts);
3370+ return this.removeEventListener(name,arguments.callee,false);
3371+ e.preventDefault();
3373+ Value.addListener(document, name, update);
3376+ listen("touchstart", start);
3377+ listen("touchmove", function(_){});
3378+ listen("touchend", end);
3379+ listen("touchcancel", end);
3380+ listen("touchleave", end);
3382+ function dependency(f) {
3383+ var signal = Elm.Signal.lift(f)(root);
3384+ root.defaultNumberOfKids += 1;
3385+ signal.defaultNumberOfKids = 0;
3389+ var touches = dependency(function(ts) {
3390+ return Elm.JavaScript.castJSArrayToList(ts);
3392+ var taps = function() {
3393+ function pred(_) { var b = hasTap; hasTap = false; return b; }
3394+ var sig = dependency(function(_) { return tap; });
3395+ return Elm.Signal.keepIf(pred)({_:[true],x:[0],y:[0]})(sig);
3398+ return { touches: touches, taps: taps };
3306Elm.Dict=function(){
3400Elm.Dict=function(){
3307 var compare = Elm.Prelude.compare;
3401 var compare = Elm.Prelude.compare;
3308 var uncurry = Elm.Prelude.uncurry;
3402 var uncurry = Elm.Prelude.uncurry;