on master help sign in
Add the beginnings of a button module and mess with the definition of equality.
commit24d508b8d23f5793e72563ffe9f57602ebd1d94d authorevancz <info@elm-lang.org> dateThu 7 Mar 2013, 23:17 (14 years ago) parent35c5086
2 files changed+16−10
libraries/Input/Button.elm+6 libraries/Native/Misc.js+10−10
libraries/Input/Button.elmnew file+6
@@ -0,0 +1,6 @@
1+
2+module Input.Button where
3+
4+type ButtonPool t = { button : String -> t -> Element, presses : Signal t }
5+
6+buttonPool : String -> ButtonPool t
libraries/Native/Misc.js+10−10
@@ -13,18 +13,18 @@ import JSON
1313 'use strict';
1414
1515 function eq(x,y) {
16+ if (x === y) return true;
1617 if (typeof x === "object") {
17− if (x !== null && '_' in x) {
18− for (var i in x) { if (x[i] != y[i]) return false; }
19− for (var i in y) { if (!(i in x)) return false; }
20− return true;
21− }
22− if (x === y) return true;
23− if (x.length !== y.length) return false;
24− for (var i = x.length; i--; ) {
25− if (!eq(x[i],y[i])) return false;
26− }
18+ if ('_' in x) {
19+ for (var i in x) { if (!eq(x[i],y[i])) return false; }
20+ for (var i in y) { if (!(i in x)) return false; }
2721 return true;
22+ }
23+ if (x.ctor !== y.ctor) return false;
24+ for (var i = x.length; i--; ) {
25+ if (!eq(x[i],y[i])) return false;
26+ }
27+ return true;
2828 }
2929 return x === y;
3030 }