packages feed

Elm 0.3.0 → 0.3.5

raw patch · 17 files changed

+365/−120 lines, 17 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

Elm.cabal view
@@ -1,6 +1,6 @@  Name:                Elm-Version:             0.3.0+Version:             0.3.5 Synopsis:            The Elm language module. Description:         Elm aims to make client-side web-development more pleasant.                      It is a statically/strongly typed, functional reactive@@ -22,7 +22,7 @@ Build-type:          Simple  Extra-source-files:  changelog.txt-Data-files:          elm-runtime-0.3.0.js+Data-files:          elm-runtime-0.3.5.js Cabal-version:       >=1.8  source-repository head@@ -48,6 +48,7 @@                        ParseExpr,                        ParseTypes,                        ParseModules,+                       ParseForeign,                        Types,                        Constrain,                        Hints,@@ -84,6 +85,7 @@                        ParseExpr,                        ParseTypes,                        ParseModules,+                       ParseForeign,                        Types,                        Constrain,                        Hints,
changelog.txt view
@@ -1,3 +1,52 @@+
+Release 0.3.5
+=============
+
+* Add JavaScript event interface. Allows Elm to import and export JS values
+  and events. This makes it possible to import and export Elements, so users
+  can use JS techniques and libraries if necessary. Conversion between JS
+  and Elm values happens with functions from here:
+    http://localhost:8000/docs/Foreign/JavaScript.elm
+    http://localhost:8000/docs/Foreign/JavaScript/Experimental.elm
+
+* Add new flags to help with JavaScript event interface.
+
+* Add three built-in event listeners (elm_title, elm_log, elm_redirect) that
+  make it possible to make some common/simple imperative actions without
+  having to worry about writing the JS yourself. For example:
+        foreign export jsevent "elm_title"
+            title :: Signal JSString
+  will update the page's title to the current value of the title signal.
+  Empty strings are ignored. "elm_redirect" and "elm_log" events work much
+  the same way, except that "elm_log" does not skip empty strings.
+
+* Add new Signal functions:
+    count       :: Signal a -> Signal Int
+    keepIf      :: (a -> Bool) -> a -> Signal a -> Signal a
+    dropIf      :: (a -> Bool) -> a -> Signal a -> Signal a
+    keepWhen    :: Signal Bool -> a -> Signal a -> Signal a
+    dropWhen    :: Signal Bool -> a -> Signal a -> Signal a
+    dropRepeats :: Signal a -> Signal a
+    sampleOn    :: Signal a -> Signal b -> Signal b
+    clicks      :: Signal ()
+  The keep and drop functions make it possible to filter events, which
+  was not possible in prior releases. More documentation:
+  http://elm-lang.org/docs/Signal/Signal.elm
+
+* Add examples of JS event interface and new signal functions:
+  https://github.com/evancz/Elm/tree/master/Examples/elm-js
+
+* Use more compressed format for strings. Should make strings 10-12 times
+  more space efficient than in previous releases. Anecdotal evidence:
+  Elm's home page is now 70% of its previous size.
+
+* Add new function to Data.List:
+    last :: [a] -> a
+
+* Fix parenthesization bug with binary operators.
+
+
+
 Release 0.3.0
 =============
 
− elm-runtime-0.3.0.js
@@ -1,54 +0,0 @@-var Guid=function(){var f=0;return{guid:function(){return f+=1}}}(),Value=function(){var f=function(a){a.replace('"',"&#34;");a.replace("&","&#38;");a.replace("'","&#39;");a.replace("<","&#60;");a.replace(">","&#62;");return a},b=function(a){if("boolean"===typeof a)return a?"True":"False";if("number"!==typeof a&&a[0]){if("Tuple"===a[0].substring(0,5)){for(var c="",g=a.length;--g;)c=","+b(a[g])+c;","===c[0]&&(c=c.substring(1));return"("+c+")"}if("Cons"===a[0])for(var g="string"===typeof a[1]?'"':"]",-h="string"===typeof a[1]?"":",",c=("string"===typeof a[1]?'"':"[")+b(a[1]),a=a[2];;)if("Cons"===a[0])c+=h+b(a[1]),a=a[2];else return c+g;else{if("Nil"===a[0])return"[]";c="";for(g=a.length;--g;)c=" "+b(a[g])+c;c=a[0]+c;return 1<a.length?"("+c+")":c}}return a+""};return{show:function(a){return Text.monospace(f(b(a)))},Tuple:function(){var a=arguments.length,c=Array(a+1);for(c[0]="Tuple"+arguments.length;a--;)c[a+1]=arguments[a];return c},append:function(a,c){if("string"===typeof a&&"string"===typeof c)return a.concat(c);-if("Nil"===a[0])return c;for(var b=["Cons",a[1],["Nil"]],h=b,a=a[2];"Cons"===a[0];)h[2]=["Cons",a[1],["Nil"]],a=a[2],h=h[2];h[2]=c;return b},toText:function(a){if("string"===typeof a)return a;for(var b=[];"Cons"===a[0];)b.push(a[1]),a=a[2];return f(b.join(""))},properEscape:f}}(),List=function(){function f(a){return function(e){if("Nil"===e[0])return e;"Cons"!==e[0]&&i("map");for(var d=["Cons",a(e[1]),["Nil"]],b=d,e=e[2];"Cons"===e[0];)b[2]=["Cons",a(e[1]),["Nil"]],e=e[2],b=b[2];return d}}function b(e){return function(a){return function(d){var b=-a;if("Nil"===d[0])return b;for("Cons"!==d[0]&&i("foldl");"Cons"===d[0];)b=e(d[1])(b),d=d[2];return b}}}function a(e){return function(a){return function(d){var b=a;if("Nil"===d[0])return b;"Cons"!==d[0]&&i("foldr");for(var c=[];"Cons"===d[0];)c.push(d[1]),d=d[2];for(d=c.length;d--;)b=e(c[d])(b);return b}}}function c(e){return function(a){var d;"Cons"!==a[0]?d=void 0:(d=a[1],a=a[2],d=b(e)(d)(a));return d}}function g(a){return function(e){return function(d){if("Nil"===d[0])return["Cons",e,["Nil"]];"Cons"!==-d[0]&&i("scanl");for(var b=[e];"Cons"===d[0];)e=a(d[1])(e),b.push(e),d=d[2];for(var d=["Nil"],c=b.length;c--;)d=["Cons",b[c],d];return d}}}function h(e){return function(a){return function(){for(var d=[function(e){return"Nil"!==e[0]?void 0:["Tuple2",["Nil"],["Nil"]]},function(a){if("Cons"===a[0]){var d=a[1],a=a[2];var b=h(e)(a);"Tuple2"!==b[0]?d=void 0:(a=b[1],b=b[2],d=e(d)?["Tuple2",["Cons",d,a],b]:["Tuple2",a,["Cons",d,b]]);return d}}],b=d.length;b--;){var c=d[b](a);if(void 0!==c)return c}}()}}function j(a){return function(){for(var e=-[function(a){return"Nil"!==a[0]?void 0:["Tuple2",["Nil"],["Nil"]]},function(a){if("Cons"!==a[0])a=void 0;else if(a=["Tuple2",a[1],j(a[2])],"Tuple2"!==a[0]||"Tuple2"!==a[1][0])a=void 0;else var e=a[1][1],d=a[1][2],a="Tuple2"!==a[2][0]?void 0:["Tuple2",["Cons",e,a[2][1]],["Cons",d,a[2][2]]];return a}],d=e.length;d--;){var b=e[d](a);if(void 0!==b)return b}}()}function l(a){return function(e){return function(){for(var d=[function(a){return"Nil"!==a[0]?void 0:["Nil"]},function(a){if("Cons"===a[0]){var e=-a[1];return"Nil"!==a[2][0]?void 0:["Cons",e,["Nil"]]}},function(e){if("Cons"===e[0]){var d=e[1];if("Cons"===e[2][0]){var b=e[2][1],e=e[2][2];return["Cons",d,["Cons",a,l(a)(["Cons",b,e])]]}}}],b=d.length;b--;){var c=d[b](e);if(void 0!==c)return c}}()}}function o(a){return function(e){return function(){for(var d=[function(a){return"Nil"!==a[0]?void 0:["Nil"]},function(a){if("Cons"===a[0]){var e=a[1];return"Nil"!==a[2][0]?void 0:e}},function(e){if("Cons"===e[0]){var d=e[1];if("Cons"===e[2][0]){var b=-e[2][1],e=e[2][2];return Value.append(d,Value.append(a,o(a)(["Cons",b,e])))}}}],b=d.length;b--;){var c=d[b](e);if(void 0!==c)return c}}()}}var i=function(a){throw"Function '"+a+"' expecting a list!";},k=b(function(a){return function(e){return["Cons",a,e]}})(["Nil"]),m=a(function(a){return function(e){return Value.append(a,e)}})(["Nil"]),n=b(function(a){return function(e){return a&&e}})(!0),e=b(function(a){return function(e){return a||e}})(!1),d=b(function(a){return function(e){return a+e}})(0),p=-b(function(a){return function(e){return a*e}})(1),r=c(function(a){return function(e){return Math.max(a,e)}}),t=c(function(a){return function(e){return Math.min(a,e)}});return{head:function(a){if("Cons"!==a[0])throw"Error: 'head' only accepts lists of length greater than one.";return a[1]},tail:function(a){if("Cons"!==a[0])throw"Error: 'tail' only accepts lists of length greater than one.";return a[2]},map:f,foldl:b,foldr:a,foldl1:c,foldr1:function(e){return function(d){var b;"Cons"!==d[0]?b=void 0:-(b=d[1],d=d[2],b=a(e)(b)(d));return b}},scanl:g,scanl1:function(a){return function(e){if("Cons"!==e[0])throw"Error: 'scanl1' requires a list of at least length 1.";return g(a)(e[1])(e[2])}},filter:function(a){return function(e){if("Nil"===e[0])return e;"Cons"!==e[0]&&i("filter");for(var d=[];"Cons"===e[0];)a(e[1])&&d.push(e[1]),e=e[2];for(var e=["Nil"],b=d.length;b--;)e=["Cons",d[b],e];return e}},length:function(a){for(var e=0;"Cons"===a[0];)e+=1,a=a[2];return e},reverse:k,concat:m,concatMap:function(a){return function(e){return m(f(a)(e))}},-and:n,or:e,forall:function(a){return b(function(e){return function(d){return d&&a(e)}})(!0)},exists:function(a){return b(function(e){return function(d){return d||a(e)}})(!1)},sum:d,product:p,maximum:r,minimum:t,partition:h,zipWith:function(a){return function(e){return function(d){if("Nil"===e[0]||"Nil"===d[0])return["Nil"];("Cons"!==e[0]||"Cons"!==d[0])&&i("zipWith");for(var b=[];"Cons"===e[0]&&"Cons"===d[0];)b.push(a(e[1])(d[1])),e=e[2],d=d[2];for(var d=["Nil"],c=b.length;c--;)d=["Cons",b[c],d];-return d}}},zip:function(a){return function(e){if("Nil"===a[0]||"Nil"===e[0])return["Nil"];("Cons"!==a[0]||"Cons"!==e[0])&&i("zip");for(var d=[];"Cons"===a[0]&&"Cons"===e[0];)d.push(["Tuple2",a[1],e[1]]),a=a[2],e=e[2];for(var e=["Nil"],b=d.length;b--;)e=["Cons",d[b],e];return e}},unzip:j,intersperse:l,intercalate:o,sort:function(e){if("Nil"===e[0])return e;"Cons"!==e[0]&&i("sort");for(var a=[];"Cons"===e[0];)a.push(e[1]),e=e[2];a.sort(function(e,a){return e-a});for(var e=["Nil"],d=a.length;d--;)e=-["Cons",a[d],e];return e},take:function(e){return function(a){if(0>=e)return["Nil"];if("Nil"===a[0])return a;"Cons"!==a[0]&&i("take");var d=["Cons",a[1],["Nil"]],b=d,a=a[2];for(--e;"Cons"===a[0]&&0<e;)b[2]=["Cons",a[1],["Nil"]],b=b[2],a=a[2],--e;return d}},drop:function(e){return function(a){if("Nil"===a[0])return a;for("Cons"!==a[0]&&i("drop");"Cons"===a[0]&&0<e;)a=a[2],--e;return a}}}}(),Data=function(){var f=function(){return{fromCode:function(a){return String.fromCharCode(a)},toCode:function(a){return a.charCodeAt(0)},-toUpper:function(a){return a.toUpperCase()},toLower:function(a){return a.toLowerCase()},toLocaleUpper:function(a){return a.toLocaleUpperCase()},toLocaleLower:function(a){return a.toLocaleLowerCase()}}}(),b=function(){function a(a){return function(b){return"Just"===a[0]?["Cons",a[1],b]:b}}function b(a){return function(){return function(b){var c=a(c);return"Just"===c[0]?["Cons",c[1],b]:b}}}return{Just:function(a){return["Just",a]},Nothing:["Nothing"],catMaybes:List.foldr(a)(["Nil"]),isJust:function(a){return"Just"===-a[0]},isNothing:function(a){return"Nothing"===a[0]},fromMaybe:function(a){return function(b){return"Just"===b[0]?b[1]:a}},consMaybe:a,mapMaybe:function(a){return List.foldr(b(a))(["Nil"])},maybe:function(a){return function(b){return function(c){return"Just"===c[0]?b(c[1]):a}}}}}();return{String:{toText:Value.toText,properEscape:Value.properEscape},Char:f,Maybe:b,List:List}}(),Color=function(){var f=function(b,a,c,f){return{r:b,g:a,b:c,a:f}};return{black:f(0,0,0,1),white:f(255,255,255,1),red:f(255,-0,0,1),green:f(0,255,0,1),blue:f(0,0,255,1),gray:f(128,128,128,1),grey:f(128,128,128,1),yellow:f(255,255,0,1),cyan:f(0,255,255,1),magenta:f(255,0,255,1),rgba:function(b){return function(a){return function(c){return function(g){return f(b,a,c,g)}}}},rgb:function(b){return function(a){return function(c){return f(b,a,c,1)}}},Internal:{extract:function(b){return 1===b.a?"rgb("+b.r+","+b.g+","+b.b+")":"rgba("+b.r+","+b.g+","+b.b+","+b.a+")"}}}}(),Element=function(){var f=function(a){a=document.createElement(a);-a.id=Guid.guid();return a},b=function(a){var d=f("div");d.appendChild(a);return d},a=function(a){return function(d){return function(b){var c=f("div");c.isElmLeaf=!0;c.isElmText=!0;c.innerHTML=b;c.style.textAlign=d;0<a&&(c.style.width=a+"px");return c}}},c=a(0)("left"),g=a(0)("justify"),h=a(0)("center"),j=a(0)("right"),l=function(a){return"DIV"===a.tagName?a:b(a)},o=function(a){a.style.styleFloat="left";a.style.cssFloat="left";return a},i=function(a){a.style.position="absolute";return a},k=function(a,-d,b){for(var c=f("div"),i=b.length;i--;){var h=d(b[i]);c.appendChild(h)}c.elmFlowDirection=a;return c},m=function(a){return function(d){for(var b=[];"Cons"===d[0];)b.push(d[1]),d=d[2];3<=a&&b.reverse();d=a%3;if(0==d)return k("Y",l,b);if(1==d)return k("X",o,b);if(2==d)return k("Z",i,b)}},n=function(e){return function(d){if("A"===d.tagName)return n(e)(d.firstChild),d;if(d.hasOwnProperty("isElmText")){var b=a(e)(d.style.textAlign)(d.innerHTML);d.style.height=b.style.height}d.style.width=e+"px";return d}};-return{text:c,image:function(a){var d=f("img");d.isElmLeaf=!0;d.onload=function(){""===d.style.width&&0<this.width&&(d.style.width=d.width=this.width+"px");""===d.style.height&&0<this.height&&(d.style.height=d.height=this.height+"px");Dispatcher.adjust()};d.src=Data.String.toText(a);d.name=d.src;return d},fittedImage:function(a){return function(d){return function(b){var c=f("canvas");c.style.width=a+"px";c.style.height=d+"px";c.width=a;c.height=d;c.innerHTML="Your browser does not support the canvas element.";-c.isElmLeaf=!0;var i=f("img");i.onload=function(){if(c.getContext){var b=c.getContext("2d"),h=0,f=0,g=this.width,k=this.height;a/d>this.width/this.height?(k=this.width*d/a,f=(this.height-k)/2):(g=this.height*a/d,h=(this.width-g)/2);b.drawImage(i,h,f,g,k,0,0,c.width,c.height)}};i.src=Data.String.toText(b);return c}}},video:function(a){var a=Data.String.toText(a),d=f("video");d.controls="controls";var b=f("source");b.src=a;b.type="video/"+a.substring(a.length-3,a.length);d.appendChild(b);d.isElmLeaf=-!0;return d},audio:function(a){var a=Data.String.toString(a),d=f("video");d.controls="controls";var b=f("source");b.src=a;b.type="audio/"+a.substring(a.length-3,a.length);d.appendChild(b);d.isElmLeaf=!0;return d},collage:function(a){return function(d){return function(b){var c=f("canvas");c.style.width=a+"px";c.style.height=d+"px";c.width=a;c.height=d;if(c.getContext){var i=c.getContext("2d");for(i.clearRect(0,0,c.width,c.height);"Cons"===b[0];)i=b[1](i),b=b[2];return c}c.innerHTML="Your browser does not support the canvas element.";-c.isElmLeaf=!0;return c}}},flow:m,layers:m(2),rectangle:function(a){return function(d){var b=f("div");b.isElmLeaf=!0;b.style.width=a+"px";b.style.height=d+"px";return b}},beside:function(a){return function(d){return m(4)(["Cons",a,["Cons",d,["Nil"]]])}},above:function(a){return function(d){return m(3)(["Cons",a,["Cons",d,["Nil"]]])}},below:function(a){return function(d){return m(0)(["Cons",a,["Cons",d,["Nil"]]])}},box:function(a){return function(d){d.style.position="absolute";d.style.margin="auto";-var b=(a-1)%3,c=(a-1)/3;2>b&&(d.style.left=0);0<b&&(d.style.right=0);2>c&&(d.style.top=0);0<c&&(d.style.bottom=0);b=f("div");b.style.position="relative";b.appendChild(d);return b}},width:n,height:function(a){return function(b){("A"===b.tagName?b.firstChild:b).style.height=a+"px";return b}},size:function(a){return function(b){return function(c){var i="A"===c.tagName?c.firstChild:c;i.style.width=a+"px";i.style.height=b+"px";return c}}},color:function(a){return function(b){b.style.backgroundColor=Color.Internal.extract(a);-return b}},opacity:function(a){return function(b){b.style.opacity=a;return b}},link:function(a){return function(d){var c=f("a");c.href=Text.fromString(a);c.appendChild(d);return b(c)}},asText:function(b){return a(0)("left")(Value.show(b))},plainText:function(b){return a(0)("left")(Data.String.toText(b))},justifiedText:g,centeredText:h,rightedText:j,up:0,left:1,inward:2,down:3,right:4,outward:5,correctTextSize:function(a){var b=a.style.width?a.style.width.slice(0,-2):0,c=f("div");c.innerHTML=a.innerHTML;-c.style.textAlign=a.style.textAlign;0<b&&(c.style.width=b+"px");c.style.visibility="hidden";c.style.styleFloat="left";c.style.cssFloat="left";document.body.appendChild(c);var i=window.getComputedStyle(c);0>=b&&(a.style.width=i.getPropertyValue("width"));a.style.height=i.getPropertyValue("height");document.body.removeChild(c)}}}(),Text=function(){var f=function(a){if("string"===typeof a)return a;for(var b=[];"Cons"===a[0];)b.push(a[1]),a=a[2];return Data.String.properEscape(b.join(""))},b=function(a){return function(b){return"<"+-a+">"+b+"</"+a+">"}},a=function(a,b){return function(c){return"<span style='"+a+":"+b+"'>"+c+"</span>"}},c=b("h1"),g=a("font-style","italic"),b=b("b"),h=a("text-decoration","underline"),j=a("text-decoration","overline"),l=a("text-decoration","line-through");return{fromString:f,toText:f,header:c,height:function(b){return a("font-size",b+"em")},italic:g,bold:b,underline:h,overline:j,strikeThrough:l,monospace:a("font-family","monospace"),color:function(b){return a("color",Color.Internal.extract(b))},-link:function(a){return function(b){return"<a href='"+f(a)+"'>"+b+"</a>"}}}}(),Shape=function(){var f=function(a,b,f,h){return{center:a,points:b,theta:f,scale:h}},b=function(a){return function(b){return function(f){return function(h){h.save();h.translate(f.center[0],f.center[1]);h.rotate(f.theta);h.scale(f.scale,f.scale);h.beginPath();var j=f.points;h.moveTo(j[0][0],j[0][1]);for(var l=j.length;l--;)h.lineTo(j[l][0],j[l][1]);h.closePath();a?(h.fillStyle=Color.Internal.extract(b),h.fill()):(h.strokeStyle=-Color.Internal.extract(b),h.stroke());h.restore();return h}}}};return{polygon:function(a){return function(b){for(var g=[];"Cons"===a[0];)g.push([a[1][1],a[1][2]]),a=a[2];b=[b[1],b[2]];return f(b,g,0,1)}},ngon:function(a){return function(b){return function(g){for(var h=[],j=a;j--;)h.push([b*Math.cos(2*Math.PI*j/a),b*Math.sin(2*Math.PI*j/a)]);g=[g[1],g[2]];return f(g,h,0,1)}}},rect:function(a){return function(b){return function(g){var h=[[-a/2,-b/2],[a/2,-b/2],[a/2,b/2],[-a/2,b/2]],g=[g[1],g[2]];return f(g,-h,0,1)}}},oval:function(a){return function(b){return function(g){for(var h=[],j=2*Math.PI;0<j;j-=Math.PI/50)h.push([a/2*Math.cos(j),b/2*Math.sin(j)]);g=[g[1],g[2]];return f(g,h,0,1)}}},move:function(a){return function(b){return function(g){return f([a+g.center[0],b+g.center[1]],g.points,g.theta,g.scale)}}},rotate:function(a){return function(b){return f(b.center,b.points,b.theta+2*Math.PI*a,b.scale)}},scale:function(a){return function(b){return f(b.center,b.points,b.theta,b.scale*a)}},filled:b(!0),-outlined:b(!1),customOutline:function(a){return function(b){return function(f){f.points.push(f.points[0]);return Line.customLine(a)(b)(f)}}}}}(),Line=function(){var f=function(b){return function(a){return function(c){if("string"===typeof b[0]){for(var f=[];"Cons"===b[0];)f.push(b[1]),b=b[2];b=f}0===b.length&&(b=[8,4]);return function(f){f.save();f.beginPath();f.translate(c.center[0],c.center[1]);f.rotate(c.theta);f.scale(c.scale,c.scale);var g=b,l=c.points,o=l.length-1,i=l[o][0],k=l[o][1],m=0,n=0,-e=0,d=0,p=0,r=0,t=g.length,s=!0,q=g[0];for(f.moveTo(i,k);o--;){m=l[o][0];n=l[o][1];e=m-i;d=n-k;for(p=Math.sqrt(e*e+d*d);q<=p;)i+=e*q/p,k+=d*q/p,f[s?"lineTo":"moveTo"](i,k),e=m-i,d=n-k,p=Math.sqrt(e*e+d*d),s=!s,r=(r+1)%t,q=g[r];0<p&&(f[s?"lineTo":"moveTo"](m,n),q-=p);i=m;k=n}f.strokeStyle=Color.Internal.extract(a);f.stroke();f.restore();return f}}}};return{line:function(b){for(var a=[];"Cons"===b[0];)a.push([b[1][1],b[1][2]]),b=b[2];return{center:[0,0],points:a,theta:0,scale:1}},customLine:f,solid:function(b){return function(a){return function(c){c.save();-c.beginPath();c.translate(a.center[0],a.center[1]);c.rotate(a.theta);c.scale(a.scale,a.scale);var f=a.points,h=f.length;for(c.moveTo(f[h-1][0],f[h-1][1]);h--;)c.lineTo(f[h][0],f[h][1]);c.strokeStyle=Color.Internal.extract(b);c.stroke();c.restore();return c}}},dashed:f([8,4]),dotted:f([3,3])}}(),Elm=function(){var f=function(a,b,c){for(var f=a.length;f--;)a[f].recv(b,c)},b=function(a){this.id=Guid.guid();this.value=a;this.kids=[];this.recv=function(a,b,c){if(b=b===this.id)this.value=c;f(this.kids,-a,b)};Dispatcher.inputs.push(this)},a=function(a,b){this.id=Guid.guid();this.value=null;this.kids=[];this.inbox={};b.reverse();this.recalc=function(){for(var c=a,f=b.length;f--;)c=c(b[f].value);this.value=c};this.recalc();this.recv=function(a,c){this.inbox.hasOwnProperty(a)||(this.inbox[a]={changed:!1,count:0});var i=this.inbox[a];i.count+=1;c&&(i.changed=!0);i.count==b.length&&(i.changed&&this.recalc(),f(this.kids,a,i.changed),delete this.inbox[a])};for(var c=b.length;c--;)b[c].kids.push(this)},-c=function(a,b,c){this.id=Guid.guid();this.value=b;this.kids=[];this.recv=function(b,h){h&&(this.value=a(c.value)(this.value));f(this.kids,b,h)};c.kids.push(this)};return{Input:function(a){return new b(a)},Lift:function(b,c){return new a(b,c)},Fold:function(a,b,f){return new c(a,b,f)}}}(),Dispatcher=function(){var f=null,b=0,a=[],c=function(a){var b=a.childNodes,f=b.length;if(a.hasOwnProperty("isElmLeaf")){a.hasOwnProperty("isElmText")&&Element.correctTextSize(a);var b=""===a.style.width?0:a.style.width.slice(0,--2)-0,g=""===a.style.height?0:a.style.height.slice(0,-2)-0;return[b,g]}if(1===f){var i=c(b[0]);""!==a.style.width&&(i[0]=a.style.width.slice(0,-2)-0);""!==a.style.height&&(i[1]=a.style.height.slice(0,-2)-0);0!==i[0]&&(a.style.width=i[0]+"px");0!==i[1]&&(a.style.height=i[1]+"px");return i}for(var k=0,m=g=0,n=0,e=!0,d=!0;f--;)i=c(b[f]),k=Math.max(k,i[0]),g=Math.max(g,i[1]),m+=i[0],n+=i[1],e=e&&0<i[0],d=d&&0<i[1];b=k;f=a.elmFlowDirection;"X"===f&&(b=e?m:0);"Y"===f&&(g=d?n:0);0<b&&(a.style.width=b+"px");-0<g&&(a.style.height=g+"px");return[b,g]},g=function(){var a=document.getElementById("content");c(a.children[0])};return{initialize:function(){var a=ElmCode.hasOwnProperty("main")?ElmCode.main:main;try{f=a()}catch(b){throw b;}f.hasOwnProperty("recv")||(f=Elm.Input(f));document.getElementById("content").appendChild(f.value);g();a=document.getElementById("widthChecker").offsetWidth;a!==window.innerWidth&&Dispatcher.notify(Window.dimensions.id,Value.Tuple(a,window.innerHeight));f=Elm.Lift(function(a){var b=-document.getElementById("content"),c=b.children[0];b.replaceChild(a,c);delete c;g();return a},[f])},notify:function(c,f){b+=1;for(var g=a.length;g--;)a[g].recv(b,c,f)},adjust:g,inputs:a}}(),Signal=function(){function f(a){for(var b=["Nil"],c=a.length;c--;)b=["Cons",a[c],b];return b}var b=function(){return document.addEventListener?function(a,b,c){a.addEventListener(b,c,!1)}:function(a,b,c){a.attachEvent("on"+b,c)}}(),a=function(){function a(b){var d=0,c=0;b||(b=window.event);if(b.pageX||b.pageY)d=-b.pageX,c=b.pageY;else if(b.clientX||b.clientY)d=b.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,c=b.clientY+document.body.scrollTop+document.documentElement.scrollTop;return Value.Tuple(d,c)}var c=Elm.Input(Value.Tuple(0,0)),f=Elm.Input(!1),g=Elm.Input(!1);b(document,"click",function(){Dispatcher.notify(g.id,!0);Dispatcher.notify(g.id,!1)});b(document,"mousedown",function(){Dispatcher.notify(f.id,!0)});b(document,"mouseup",function(){Dispatcher.notify(f.id,!1)});b(document,-"mousemove",function(b){Dispatcher.notify(c.id,a(b))});return{position:c,x:Elm.Lift(function(a){return a[1]},[c]),y:Elm.Lift(function(a){return a[2]},[c]),isClicked:g,isDown:f,clickedOn:function(a){var d=Elm.Input(!1);b(a,"click",function(){Dispatcher.notify(d.id,!0);Dispatcher.notify(d.id,!1)});return Value.Tuple(a,d)}}}(),c=function(){return{every:function(a){var a=1E3*a,b=Elm.Input(0),c=0;setInterval(function(){c+=a;Dispatcher.notify(b.id,c/1E3)},a);return b},after:function(a){var a=1E3*a,b=Elm.Input(!1);-setTimeout(function(){Dispatcher.notify(b.id,!0)},a);return b},before:function(a){var a=1E3*a,b=Elm.Input(!0);setTimeout(function(){Dispatcher.notify(b.id,!1)},a);return b}}}(),g=function(){var a=Elm.Input(Value.Tuple(window.innerWidth,window.innerHeight));b(window,"resize",function(){var b=document.getElementById("widthChecker").offsetWidth;Dispatcher.notify(a.id,Value.Tuple(b,window.innerHeight))});return{dimensions:a,width:Elm.Lift(function(a){return a[1]},[a]),height:Elm.Lift(function(a){return a[2]},-[a])}}(),h={Raw:function(){function a(b,c){return"Nil"===c[0]?c:c[1]===b?c[2]:["Cons",c[1],a(b,c[2])]}var c=Elm.Input(["Nil"]),f=Elm.Input(["Nothing"]);b(document,"keydown",function(a){var b;a:{for(b=c.value;"Nil"!==b[0];){if(b[1]===a.keyCode){b=!0;break a}b=b[2]}b=!1}b||Dispatcher.notify(c.id,["Cons",a.keyCode,c.value])});b(document,"keyup",function(b){b=a(b.keyCode,c.value);Dispatcher.notify(c.id,b)});b(window,"blur",function(){Dispatcher.notify(c.id,["Nil"])});b(document,"keypress",function(a){Dispatcher.notify(f.id,-["Just",a.charCode||a.keyCode]);Dispatcher.notify(f.id,["Nothing"])});return{keysDown:c,charPressed:f}}()},j=function(){var a=function(a){return function(b){var c=Elm.Input(["Waiting"]),d={};window.XMLHttpRequest?d=new XMLHttpRequest:window.ActiveXObject&&(d=new ActiveXObject("Microsoft.XMLHTTP"));d.onreadystatechange=function(){4===d.readyState&&Dispatcher.notify(c.id,200===d.status?["Success",f(d.responseText)]:["Failure",d.status,f(d.statusText)])};d.open(a,Data.String.toText(b),!0);d.send(null);-return c}},b=function(a){return function(b){var c=Elm.Input(["Nothing"]),b=Elm.Lift(function(b){if("Just"!==b[0]){try{Dispatcher.notify(c.id,["Nothing"])}catch(i){}return[]}try{Dispatcher.notify(c.id,["Just",["Waiting"]])}catch(g){c.value=["Just",["Waiting"]]}var h={};window.XMLHttpRequest?h=new XMLHttpRequest:window.ActiveXObject&&(h=new ActiveXObject("Microsoft.XMLHTTP"));h.onreadystatechange=function(){4===h.readyState&&Dispatcher.notify(c.id,["Just",200===h.status?["Success",f(h.responseText)]:-["Failure",h.status,f(h.statusText)]])};h.open(a,Data.String.toText(b[1]),!0);h.send(null);return[]},[b]);return Elm.Lift(function(a){return function(){return a}},[c,b])}};return{get:a("GET"),post:a("POST"),gets:b("GET"),posts:b("POST")}}(),l=function(){return{inRange:function(a){return function(b){return Elm.Input(Math.floor(Math.random()*(b-a+1))+a)}},randomize:function(a){return function(b){return function(c){return Elm.Lift(function(){return Math.floor(Math.random()*(b-a+1))+a},[c])}}}}}(),o=-function(){var a=function(a){a.isElmLeaf=!0;var c=Elm.Input(["Nil"]);b(a,"keyup",function(){Dispatcher.notify(c.id,f(a.value));a.focus()});return Value.Tuple(a,c)},c=function(a){a=document.createElement(a);a.id=Guid.guid();return a},g=function(a){for(var e=c("select"),d=[];"Cons"===a[0];){var f=c("option"),g=Text.toText(a[1][1]);f.value=g;f.innerHTML=g;e.appendChild(f);d.push(a[1][2]);a=a[2]}var i=Elm.Input(d[0]);b(e,"change",function(){Dispatcher.notify(i.id,d[e.selectedIndex])});return Value.Tuple(e,-i)};return{textArea:function(b){return function(e){var d=c("textarea");d.rows=e;d.cols=b;return a(d,"")}},textField:function(b){var e=c("input");e.type="text";return a(e,b)},password:function(b){var e=c("input");e.type="password";return a(e,b)},checkbox:function(a){var e=c("input");e.type="checkbox";e.checked=a;var d=Elm.Input(a);b(e,"change",function(){Dispatcher.notify(d.id,e.checked)});return Value.Tuple(e,d)},dropDown:g,stringDropDown:function(a){return g(List.map(function(a){return Value.Tuple(a,-a)})(a))},button:function(a){var e=c("input");e.type="button";e.value=Text.toText(a);var d=Elm.Input(!1);b(e,"click",function(){Dispatcher.notify(d.id,!0);Dispatcher.notify(d.id,!1)});return Value.Tuple(e,d)}}}();return{Mouse:a,Keyboard:h,Time:c,Window:g,HTTP:j,Random:l,Input:o,constant:function(a){return Elm.Input(a)},lift:function(a){return function(b){return Elm.Lift(a,[b])}},lift2:function(a){return function(b){return function(c){return Elm.Lift(a,[b,c])}}},lift3:function(a){return function(b){return function(c){return function(f){return Elm.Lift(a,-[b,c,f])}}}},lift4:function(a){return function(b){return function(c){return function(f){return function(e){return Elm.Lift(a,[b,c,f,e])}}}}},foldp:function(a){return function(b){return function(c){return Elm.Fold(a,b,c)}}}}}(),Prelude=function(){var f=function(b){return function(a){var c=b%a,c=0==b?0:0<a?0<=b?c:c+a:-f(-b)(-a);return c==a?0:c}};return{id:function(b){return b},not:function(b){return!b},fst:function(b){return b[1]},snd:function(b){return b[2]},rem:function(b){return function(a){return b%-a}},sqrt:Math.sqrt,abs:Math.abs,pi:Math.PI,sin:Math.sin,cos:Math.cos,tan:Math.tan,asin:Math.asin,acos:Math.acos,atan:Math.atan,mod:f,min:function(b){return function(a){return Math.min(b,a)}},max:function(b){return function(a){return Math.max(b,a)}},flip:function(b){return function(a){return function(c){return b(c)(a)}}},clamp:function(b){return function(a){return function(c){return Math.min(a,Math.max(b,c))}}},curry:function(b){return function(a){return function(c){return b(["Tuple2",a,c])}}},uncurry:function(b){return function(a){if("Tuple2"!==-a[0])throw"Function was uncurry'd but was not given a pair.";return b(a[1])(a[2])}},logBase:function(b){return function(a){return Math.log(a)/Math.log(b)}},Just:Data.Maybe.Just,Nothing:Data.Maybe.Nothing,maybe:Data.Maybe.maybe,map:Data.List.map,filter:Data.List.filter,head:Data.List.head,tail:Data.List.tail,length:Data.List.length,reverse:Data.List.reverse,foldr:Data.List.foldr,foldr1:Data.List.foldr1,foldl:Data.List.foldl,foldl1:Data.List.foldl1,and:Data.List.and,or:Data.List.or,forall:Data.List.forall,-exists:Data.List.exists,sum:Data.List.sum,product:Data.List.product,concat:Data.List.concat,concatMap:Data.List.concatMap,maximum:Data.List.maximum,minimum:Data.List.minimum,scanl:Data.List.scanl,scanl1:Data.List.scanl1,take:Data.List.take,drop:Data.List.drop,lift:Signal.lift,lift2:Signal.lift2,lift3:Signal.lift3,lift4:Signal.lift4,foldp:Signal.foldp,constant:Signal.constant}}(),eq=function(f,b){if("object"===typeof f){if(f===b)return!0;if(f.length!==b.length)return!1;for(var a=f.length;a--;)if(!eq(f[a],-b[a]))return!1;return!0}return f===b},includeGlobal=this;-(function(){var f=function(a){for(var b in a)if("Internal"!==b)try{includeGlobal[b]=a[b]}catch(f){"length"===b&&(includeGlobal.execScript("var length;"),length=a[b])}},b=function(a){return function(b){includeGlobal[a]=includeGlobal[a]||{};for(var f in b)"Internal"!==f&&(includeGlobal[a][f]=b[f])}};f(Element);f(Text);color=Element.color;height=Element.height;show=Value.show;f(Color);f(Shape);f(Line);b("Time")(Signal.Time);b("Mouse")(Signal.Mouse);b("Keyboard")(Signal.Keyboard);b("Window")(Signal.Window);-b("HTTP")(Signal.HTTP);b("Input")(Signal.Input);b("Random")(Signal.Random)})();var ElmCode={};ElmCode.Data=Data;ElmCode.Signal=Signal;ElmCode.Data.List=List;ElmCode.Prelude=Prelude;
+ elm-runtime-0.3.5.js view
@@ -0,0 +1,60 @@+var Guid=function(){var d=0;return{guid:function(){return d+=1}}}(),Foreign=function(){return{JavaScript:function(){function d(a){for(var b=["Nil"],c=a.length;c--;)b=["Cons",a[c],b];return b}function c(a){for(var b=[];"Cons"===a[0];)b.push(a[1]),a=a[2];return b}function b(a){return a.slice(1)}function a(a){return a.unshift("Tuple"+a.length)}return{castJSBoolToBool:function(a){return a},castBoolToJSBool:function(a){return a},castJSNumberToFloat:function(a){return a},castFloatToJSNumber:function(a){return a},+castJSNumberToInt:function(a){return~~a},castIntToJSNumber:function(a){return a},Experimental:{castJSElementToElement:function(a){return Element.jsElement(a)},castElementToJSElement:function(a){return a}},castJSArrayToList:d,castListToJSArray:c,castJSStringToString:d,castStringToJSString:function(a){return"string"===typeof a?a:c(a).join("")},castTupleToJSTuple2:b,castTupleToJSTuple3:b,castTupleToJSTuple4:b,castTupleToJSTuple5:b,castJSTupleToTuple2:a,castJSTupleToTuple3:a,castJSTupleToTuple4:a,castJSTupleToTuple5:a}}()}}(),+Value=function(){var d=function(a,b){if("object"===typeof a){if(a===b)return!0;if(a.length!==b.length)return!1;for(var c=a.length;c--;)if(!d(a[c],b[c]))return!1;return!0}return a===b},c=function(a){a.replace('"',"&#34;");a.replace("&","&#38;");a.replace("'","&#39;");a.replace("<","&#60;");a.replace(">","&#62;");return a},b=function(a){if("boolean"===typeof a)return a?"True":"False";if("number"!==typeof a&&a[0]){if("Tuple"===a[0].substring(0,5)){for(var c="",i=a.length;--i;)c=","+b(a[i])+c;","===c[0]&&+(c=c.substring(1));return"("+c+")"}if("Cons"===a[0])for(var i="string"===typeof a[1]?'"':"]",d="string"===typeof a[1]?"":",",c=("string"===typeof a[1]?'"':"[")+b(a[1]),a=a[2];;)if("Cons"===a[0])c+=d+b(a[1]),a=a[2];else return c+i;else{if("Nil"===a[0])return"[]";c="";for(i=a.length;--i;)c=" "+b(a[i])+c;c=a[0]+c;return 1<a.length?"("+c+")":c}}return a+""};return{eq:d,str:function(a){for(var b=["Nil"],c=a.length;c--;)b=["Cons",a[c],b];return b},show:function(a){return Text.monospace(c(b(a)))},Tuple:function(){var a=+arguments.length,b=Array(a+1);for(b[0]="Tuple"+arguments.length;a--;)b[a+1]=arguments[a];return b},append:function(a,b){if("string"===typeof a&&"string"===typeof b)return a.concat(b);if("Nil"===a[0])return b;for(var c=["Cons",a[1],["Nil"]],d=c,a=a[2];"Cons"===a[0];)d[2]=["Cons",a[1],["Nil"]],a=a[2],d=d[2];d[2]=b;return c},listToArray:function(a){for(var b=[];"Cons"===a[0];)b.push(a[1]),a=a[2];return b},toText:function(a){if("string"===typeof a)return a;for(var b=[];"Cons"===a[0];)b.push(a[1]),a=a[2];+return c(b.join(""))},properEscape:c}}(),List=function(){function d(a){return function(f){if("Nil"===f[0])return f;"Cons"!==f[0]&&e("map");for(var b=["Cons",a(f[1]),["Nil"]],g=b,f=f[2];"Cons"===f[0];)g[2]=["Cons",a(f[1]),["Nil"]],f=f[2],g=g[2];return b}}function c(a){return function(f){return function(b){var g=f;if("Nil"===b[0])return g;for("Cons"!==b[0]&&e("foldl");"Cons"===b[0];)g=a(b[1])(g),b=b[2];return g}}}function b(a){return function(f){return function(b){var g=f;if("Nil"===b[0])return g;"Cons"!==+b[0]&&e("foldr");for(var c=[];"Cons"===b[0];)c.push(b[1]),b=b[2];for(b=c.length;b--;)g=a(c[b])(g);return g}}}function a(a){return function(f){var b;"Cons"!==f[0]?b=void 0:(b=f[1],f=f[2],b=c(a)(b)(f));return b}}function h(a){return function(f){return function(b){if("Nil"===b[0])return["Cons",f,["Nil"]];"Cons"!==b[0]&&e("scanl");for(var g=[f];"Cons"===b[0];)f=a(b[1])(f),g.push(f),b=b[2];for(var b=["Nil"],c=g.length;c--;)b=["Cons",g[c],b];return b}}}function i(a){return function(b){return function(){for(var f=+[function(a){return"Nil"!==a[0]?void 0:["Tuple2",["Nil"],["Nil"]]},function(b){if("Cons"===b[0]){var f=b[1],b=b[2];var g=i(a)(b);"Tuple2"!==g[0]?f=void 0:(b=g[1],g=g[2],f=a(f)?["Tuple2",["Cons",f,b],g]:["Tuple2",b,["Cons",f,g]]);return f}}],g=f.length;g--;){var c=f[g](b);if(void 0!==c)return c}}()}}function l(a){return function(){for(var b=[function(a){return"Nil"!==a[0]?void 0:["Tuple2",["Nil"],["Nil"]]},function(a){if("Cons"!==a[0])a=void 0;else if(a=["Tuple2",a[1],l(a[2])],"Tuple2"!==a[0]||"Tuple2"!==+a[1][0])a=void 0;else var b=a[1][1],f=a[1][2],a="Tuple2"!==a[2][0]?void 0:["Tuple2",["Cons",b,a[2][1]],["Cons",f,a[2][2]]];return a}],f=b.length;f--;){var g=b[f](a);if(void 0!==g)return g}}()}function n(a){return function(b){return function(){for(var f=[function(a){return"Nil"!==a[0]?void 0:["Nil"]},function(a){if("Cons"===a[0]){var b=a[1];return"Nil"!==a[2][0]?void 0:["Cons",b,["Nil"]]}},function(b){if("Cons"===b[0]){var f=b[1];if("Cons"===b[2][0]){var g=b[2][1],b=b[2][2];return["Cons",f,["Cons",+a,n(a)(["Cons",g,b])]]}}}],g=f.length;g--;){var c=f[g](b);if(void 0!==c)return c}}()}}function o(a){return function(b){return function(){for(var f=[function(a){return"Nil"!==a[0]?void 0:["Nil"]},function(a){if("Cons"===a[0]){var b=a[1];return"Nil"!==a[2][0]?void 0:b}},function(b){if("Cons"===b[0]){var f=b[1];if("Cons"===b[2][0]){var g=b[2][1],b=b[2][2];return Value.append(f,Value.append(a,o(a)(["Cons",g,b])))}}}],g=f.length;g--;){var c=f[g](b);if(void 0!==c)return c}}()}}var e=function(a){throw"Function '"++a+"' expecting a list!";},j=c(function(a){return function(b){return["Cons",a,b]}})(["Nil"]),k=b(function(a){return function(b){return Value.append(a,b)}})(["Nil"]),m=c(function(a){return function(b){return a&&b}})(!0),f=c(function(a){return function(b){return a||b}})(!1),g=c(function(a){return function(b){return a+b}})(0),t=c(function(a){return function(b){return a*b}})(1),q=a(function(a){return function(b){return Math.max(a,b)}}),s=a(function(a){return function(b){return Math.min(a,b)}});return{head:function(a){if("Cons"!==+a[0])throw"Error: 'head' only accepts lists of length greater than one.";return a[1]},tail:function(a){if("Cons"!==a[0])throw"Error: 'tail' only accepts lists of length greater than one.";return a[2]},last:function(a){if("Cons"!==a[0])throw"Error: 'last' only accepts lists of length greater than one.";for(var b=a[1];"Cons"===a[0];)b=a[1],a=a[2];return b},map:d,foldl:c,foldr:b,foldl1:a,foldr1:function(a){return function(f){var g;"Cons"!==f[0]?g=void 0:(g=f[1],f=f[2],g=b(a)(g)(f));return g}},scanl:h,+scanl1:function(a){return function(b){if("Cons"!==b[0])throw"Error: 'scanl1' requires a list of at least length 1.";return h(a)(b[1])(b[2])}},filter:function(a){return function(b){if("Nil"===b[0])return b;"Cons"!==b[0]&&e("filter");for(var f=[];"Cons"===b[0];)a(b[1])&&f.push(b[1]),b=b[2];for(var b=["Nil"],g=f.length;g--;)b=["Cons",f[g],b];return b}},length:function(a){for(var b=0;"Cons"===a[0];)b+=1,a=a[2];return b},reverse:j,concat:k,concatMap:function(a){return function(b){return k(d(a)(b))}},and:m,+or:f,forall:function(a){return c(function(b){return function(f){return f&&a(b)}})(!0)},exists:function(a){return c(function(b){return function(f){return f||a(b)}})(!1)},sum:g,product:t,maximum:q,minimum:s,partition:i,zipWith:function(a){return function(b){return function(f){if("Nil"===b[0]||"Nil"===f[0])return["Nil"];("Cons"!==b[0]||"Cons"!==f[0])&&e("zipWith");for(var g=[];"Cons"===b[0]&&"Cons"===f[0];)g.push(a(b[1])(f[1])),b=b[2],f=f[2];for(var f=["Nil"],c=g.length;c--;)f=["Cons",g[c],f];return f}}},+zip:function(a){return function(b){if("Nil"===a[0]||"Nil"===b[0])return["Nil"];("Cons"!==a[0]||"Cons"!==b[0])&&e("zip");for(var f=[];"Cons"===a[0]&&"Cons"===b[0];)f.push(["Tuple2",a[1],b[1]]),a=a[2],b=b[2];for(var b=["Nil"],g=f.length;g--;)b=["Cons",f[g],b];return b}},unzip:l,intersperse:n,intercalate:o,sort:function(a){if("Nil"===a[0])return a;"Cons"!==a[0]&&e("sort");for(var b=[];"Cons"===a[0];)b.push(a[1]),a=a[2];b.sort(function(a,b){return a-b});for(var a=["Nil"],f=b.length;f--;)a=["Cons",b[f],+a];return a},take:function(a){return function(b){if(0>=a)return["Nil"];if("Nil"===b[0])return b;"Cons"!==b[0]&&e("take");var f=["Cons",b[1],["Nil"]],g=f,b=b[2];for(--a;"Cons"===b[0]&&0<a;)g[2]=["Cons",b[1],["Nil"]],g=g[2],b=b[2],--a;return f}},drop:function(a){return function(b){if("Nil"===b[0])return b;for("Cons"!==b[0]&&e("drop");"Cons"===b[0]&&0<a;)b=b[2],--a;return b}}}}(),Data=function(){var d=function(){return{fromCode:function(b){return String.fromCharCode(b)},toCode:function(b){return b.charCodeAt(0)},+toUpper:function(b){return b.toUpperCase()},toLower:function(b){return b.toLowerCase()},toLocaleUpper:function(b){return b.toLocaleUpperCase()},toLocaleLower:function(b){return b.toLocaleLowerCase()}}}(),c=function(){function b(a){return function(b){return"Just"===a[0]?["Cons",a[1],b]:b}}function a(a){return function(b){return function(c){var d=a(b);return"Just"===d[0]?["Cons",d[1],c]:c}}}return{Just:function(a){return["Just",a]},Nothing:["Nothing"],catMaybes:List.foldr(b)(["Nil"]),isJust:function(a){return"Just"===+a[0]},isNothing:function(a){return"Nothing"===a[0]},fromMaybe:function(a){return function(b){return"Just"===b[0]?b[1]:a}},consMaybe:b,mapMaybe:function(b){return List.foldr(a(b))(["Nil"])},maybe:function(a){return function(b){return function(c){return"Just"===c[0]?b(c[1]):a}}}}}();return{String:{toText:Value.toText,properEscape:Value.properEscape},Char:d,Maybe:c,List:List}}(),Color=function(){var d=function(c,b,a,d){return{r:c,g:b,b:a,a:d}};return{black:d(0,0,0,1),white:d(255,255,255,1),red:d(255,+0,0,1),green:d(0,255,0,1),blue:d(0,0,255,1),gray:d(128,128,128,1),grey:d(128,128,128,1),yellow:d(255,255,0,1),cyan:d(0,255,255,1),magenta:d(255,0,255,1),rgba:function(c){return function(b){return function(a){return function(h){return d(c,b,a,h)}}}},rgb:function(c){return function(b){return function(a){return d(c,b,a,1)}}},Internal:{extract:function(c){return 1===c.a?"rgb("+c.r+","+c.g+","+c.b+")":"rgba("+c.r+","+c.g+","+c.b+","+c.a+")"}}}}(),Element=function(){var d=function(a){a=document.createElement(a);+a.id=Guid.guid();a.style.padding="0";a.style.margin="0";return a},c=function(a){var b=d("div");b.appendChild(a);return b},b=function(a){return function(b){return function(c){var e=d("div");e.isElmLeaf=!0;e.isElmText=!0;e.innerHTML=c;e.style.textAlign=b;0<a&&(e.style.width=a+"px");return e}}},a=b(0)("left"),h=b(0)("justify"),i=b(0)("center"),l=b(0)("right"),n=function(a){return"DIV"===a.tagName?a:c(a)},o=function(a){a.style.styleFloat="left";a.style.cssFloat="left";return a},e=function(a){a.style.position=+"absolute";return a},j=function(a,b,c){for(var e=d("div"),j=c.length;j--;){var k=b(c[j]);e.appendChild(k)}e.elmFlowDirection=a;return e},k=function(a){return function(b){for(var c=[];"Cons"===b[0];)c.push(b[1]),b=b[2];3<=a&&c.reverse();b=a%3;if(0==b)return j("Y",n,c);if(1==b)return j("X",o,c);if(2==b)return j("Z",e,c)}},m=function(a){return function(g){if("A"===g.tagName)return m(a)(g.firstChild),g;if(g.hasOwnProperty("isElmText")){var c=b(a)(g.style.textAlign)(g.innerHTML);g.style.height=c.style.height}g.style.width=+a+"px";return g}};return{text:a,image:function(a){var b=d("img");b.isElmLeaf=!0;b.onload=function(){""===b.style.width&&0<this.width&&(b.style.width=b.width=this.width+"px");""===b.style.height&&0<this.height&&(b.style.height=b.height=this.height+"px");Dispatcher.adjust()};b.src=Data.String.toText(a);b.name=b.src;return b},fittedImage:function(a){return function(b){return function(c){var e=d("canvas");e.style.width=a+"px";e.style.height=b+"px";e.width=a;e.height=b;e.innerHTML="Your browser does not support the canvas element.";+e.isElmLeaf=!0;var j=d("img");j.onload=function(){if(e.getContext){var c=e.getContext("2d"),d=0,k=0,m=this.width,i=this.height;a/b>this.width/this.height?(i=this.width*b/a,k=(this.height-i)/2):(m=this.height*a/b,d=(this.width-m)/2);c.drawImage(j,d,k,m,i,0,0,e.width,e.height)}};j.src=Data.String.toText(c);return e}}},video:function(a){var a=Data.String.toText(a),b=d("video");b.controls="controls";var c=d("source");c.src=a;c.type="video/"+a.substring(a.length-3,a.length);b.appendChild(c);b.isElmLeaf=+!0;return b},audio:function(a){var a=Data.String.toString(a),b=d("video");b.controls="controls";var c=d("source");c.src=a;c.type="audio/"+a.substring(a.length-3,a.length);b.appendChild(c);b.isElmLeaf=!0;return b},collage:function(a){return function(b){return function(c){var e=d("canvas");e.style.width=a+"px";e.style.height=b+"px";e.width=a;e.height=b;if(e.getContext){var j=e.getContext("2d");for(j.clearRect(0,0,e.width,e.height);"Cons"===c[0];)j=c[1](j),c=c[2];return e}e.innerHTML="Your browser does not support the canvas element.";+e.isElmLeaf=!0;return e}}},flow:k,layers:k(2),rectangle:function(a){return function(b){var c=d("div");c.isElmLeaf=!0;c.style.width=a+"px";c.style.height=b+"px";return c}},beside:function(a){return function(b){return k(4)(["Cons",a,["Cons",b,["Nil"]]])}},above:function(a){return function(b){return k(3)(["Cons",a,["Cons",b,["Nil"]]])}},below:function(a){return function(b){return k(0)(["Cons",a,["Cons",b,["Nil"]]])}},box:function(a){return function(b){b.style.position="absolute";b.style.margin="auto";+var c=(a-1)%3,e=(a-1)/3;2>c&&(b.style.left=0);0<c&&(b.style.right=0);2>e&&(b.style.top=0);0<e&&(b.style.bottom=0);c=d("div");c.style.position="relative";c.appendChild(b);return c}},width:m,height:function(a){return function(b){("A"===b.tagName?b.firstChild:b).style.height=a+"px";return b}},size:function(a){return function(b){return function(c){var e="A"===c.tagName?c.firstChild:c;e.style.width=a+"px";e.style.height=b+"px";return c}}},color:function(a){return function(b){b.style.backgroundColor=Color.Internal.extract(a);+return b}},opacity:function(a){return function(b){b.style.opacity=a;return b}},link:function(a){return function(b){var e=d("a");e.href=Text.fromString(a);e.appendChild(b);return c(e)}},asText:function(a){return b(0)("left")(Value.show(a))},plainText:function(a){return b(0)("left")(Data.String.toText(a))},justifiedText:h,centeredText:i,rightedText:l,up:0,left:1,inward:2,down:3,right:4,outward:5,correctTextSize:function(a){var b=a.style.width?a.style.width.slice(0,-2):0,c=d("div");c.innerHTML=a.innerHTML;+c.style.textAlign=a.style.textAlign;0<b&&(c.style.width=b+"px");c.style.visibility="hidden";c.style.styleFloat="left";c.style.cssFloat="left";document.body.appendChild(c);var e=window.getComputedStyle(c);0>=b&&(a.style.width=e.getPropertyValue("width"));a.style.height=e.getPropertyValue("height");document.body.removeChild(c)},jsElement:function(a){return function(b){return function(c){var e=d("div");e.isElmLeaf=!0;e.style.width=a+"px";e.style.height=b+"px";e.appendChild(c);return e}}}}}(),Text=function(){var d=+function(a){if("string"===typeof a)return a;for(var b=[];"Cons"===a[0];)b.push(a[1]),a=a[2];return Data.String.properEscape(b.join(""))},c=function(a){return function(b){return"<"+a+' style="padding:0;margin:0">'+b+"</"+a+">"}},b=function(a,b){return function(c){return"<span style='"+a+":"+b+"'>"+c+"</span>"}},a=c("h1"),h=b("font-style","italic"),c=c("b"),i=b("text-decoration","underline"),l=b("text-decoration","overline"),n=b("text-decoration","line-through");return{fromString:d,toText:d,header:a,+height:function(a){return b("font-size",a+"em")},italic:h,bold:c,underline:i,overline:l,strikeThrough:n,monospace:b("font-family","monospace"),color:function(a){return b("color",Color.Internal.extract(a))},link:function(a){return function(b){return"<a href='"+d(a)+"'>"+b+"</a>"}}}}(),Shape=function(){var d=function(b,a,c,d){return{center:b,points:a,theta:c,scale:d}},c=function(b){return function(a){return function(c){return function(d){d.save();d.translate(c.center[0],c.center[1]);d.rotate(c.theta);+d.scale(c.scale,c.scale);d.beginPath();var l=c.points;d.moveTo(l[0][0],l[0][1]);for(var n=l.length;n--;)d.lineTo(l[n][0],l[n][1]);d.closePath();b?(d.fillStyle=Color.Internal.extract(a),d.fill()):(d.strokeStyle=Color.Internal.extract(a),d.stroke());d.restore();return d}}}};return{polygon:function(b){return function(a){for(var c=[];"Cons"===b[0];)c.push([b[1][1],b[1][2]]),b=b[2];a=[a[1],a[2]];return d(a,c,0,1)}},ngon:function(b){return function(a){return function(c){for(var i=[],l=b;l--;)i.push([a*+Math.cos(2*Math.PI*l/b),a*Math.sin(2*Math.PI*l/b)]);c=[c[1],c[2]];return d(c,i,0,1)}}},rect:function(b){return function(a){return function(c){var i=[[-b/2,-a/2],[b/2,-a/2],[b/2,a/2],[-b/2,a/2]],c=[c[1],c[2]];return d(c,i,0,1)}}},oval:function(b){return function(a){return function(c){for(var i=[],l=2*Math.PI;0<l;l-=Math.PI/50)i.push([b/2*Math.cos(l),a/2*Math.sin(l)]);c=[c[1],c[2]];return d(c,i,0,1)}}},move:function(b){return function(a){return function(c){return d([b+c.center[0],a+c.center[1]],c.points,+c.theta,c.scale)}}},rotate:function(b){return function(a){return d(a.center,a.points,a.theta+2*Math.PI*b,a.scale)}},scale:function(b){return function(a){return d(a.center,a.points,a.theta,a.scale*b)}},filled:c(!0),outlined:c(!1),customOutline:function(b){return function(a){return function(c){c.points.push(c.points[0]);return Line.customLine(b)(a)(c)}}}}}(),Line=function(){var d=function(c){return function(b){return function(a){if("string"===typeof c[0]){for(var d=[];"Cons"===c[0];)d.push(c[1]),c=+c[2];c=d}0===c.length&&(c=[8,4]);return function(d){d.save();d.beginPath();d.translate(a.center[0],a.center[1]);d.rotate(a.theta);d.scale(a.scale,a.scale);var l=c,n=a.points,o=n.length-1,e=n[o][0],j=n[o][1],k=0,m=0,f=0,g=0,h=0,q=0,s=l.length,r=!0,p=l[0];for(d.moveTo(e,j);o--;){k=n[o][0];m=n[o][1];f=k-e;g=m-j;for(h=Math.sqrt(f*f+g*g);p<=h;)e+=f*p/h,j+=g*p/h,d[r?"lineTo":"moveTo"](e,j),f=k-e,g=m-j,h=Math.sqrt(f*f+g*g),r=!r,q=(q+1)%s,p=l[q];0<h&&(d[r?"lineTo":"moveTo"](k,m),p-=h);e=k;j=m}d.strokeStyle=+Color.Internal.extract(b);d.stroke();d.restore();return d}}}};return{line:function(c){for(var b=[];"Cons"===c[0];)b.push([c[1][1],c[1][2]]),c=c[2];return{center:[0,0],points:b,theta:0,scale:1}},customLine:d,solid:function(c){return function(b){return function(a){a.save();a.beginPath();a.translate(b.center[0],b.center[1]);a.rotate(b.theta);a.scale(b.scale,b.scale);var d=b.points,i=d.length;for(a.moveTo(d[i-1][0],d[i-1][1]);i--;)a.lineTo(d[i][0],d[i][1]);a.strokeStyle=Color.Internal.extract(c);a.stroke();+a.restore();return a}}},dashed:d([8,4]),dotted:d([3,3])}}(),Elm=function(){var d=function(a,b,c){for(var d=a.kids,m=d.length;m--;)d[m].recv(b,c,a.id)},c=function(a){this.id=Guid.guid();this.value=a;this.kids=[];this.recv=function(a,b,c){if(b=b===this.id)this.value=c;d(this,a,b)};Dispatcher.inputs.push(this)},b=function(a,b){this.id=Guid.guid();this.value=null;this.kids=[];this.inbox={};b.reverse();this.recalc=function(){for(var c=a,d=b.length;d--;)c=c(b[d].value);this.value=c};this.recalc();this.recv=+function(a,c){this.inbox.hasOwnProperty(a)||(this.inbox[a]={changed:!1,count:0});var f=this.inbox[a];f.count+=1;c&&(f.changed=!0);f.count==b.length&&(f.changed&&this.recalc(),d(this,a,f.changed),delete this.inbox[a])};for(var c=b.length;c--;)b[c].kids.push(this)},a=function(a,b,c){this.id=Guid.guid();this.value=b;this.kids=[];this.recv=function(b,e){e&&(this.value=a(c.value)(this.value));d(this,b,e)};c.kids.push(this)},h=function(a,b,c){this.id=Guid.guid();this.value=a(c.value)?b:c.value;this.kids=+[];this.recv=function(b,e){var f=e&&!a(c.value);f&&(this.value=c.value);d(this,b,f)};c.kids.push(this)},i=function(a){this.id=Guid.guid();this.value=a.value;this.kids=[];this.recv=function(b,c){var k=c&&!eq(this.value,a.value);k&&(this.value=a.value);d(this,b,k)};a.kids.push(this)},l=function(a){return function(c){return function(d){d=new b(function(a){return function(b){return[a,b]}},[a,d]);d=new h(function(a){return a[0]},[!0,c],d);return new b(function(a){return a[1]},[d])}}},n=function(a,b){this.id=+Guid.guid();this.value=b.value;this.kids=[];this.inbox={};this.recv=function(c,k,m){if(k=k&&m===a.id)this.value=b.value;d(this,c,k)};a.kids.push(this);b.kids.push(this)};return{Input:function(a){return new c(a)},Lift:function(a,c){return new b(a,c)},Fold:function(b,c,d){return new a(b,c,d)},keepIf:function(a){return function(b){return function(c){return new h(function(b){return!a(b)},b,c)}}},dropIf:function(a){return function(b){return function(c){return new h(a,b,c)}}},keepWhen:function(a){return l(new b(function(a){return!a},+[a]))},dropWhen:l,dropRepeats:function(a){return new i(a)},sampleOn:function(a){return function(b){return new n(a,b)}}}}(),Dispatcher=function(){var d=null,c=0,b=[],a=function(b){var c=b.childNodes,d=c.length;if(b.hasOwnProperty("isElmLeaf")){b.hasOwnProperty("isElmText")&&Element.correctTextSize(b);var c=""===b.style.width?0:b.style.width.slice(0,-2)-0,h=""===b.style.height?0:b.style.height.slice(0,-2)-0;return[c,h]}if(1===d){var e=a(c[0]);""!==b.style.width&&(e[0]=b.style.width.slice(0,-2)-0);""!==+b.style.height&&(e[1]=b.style.height.slice(0,-2)-0);0!==e[0]&&(b.style.width=e[0]+"px");0!==e[1]&&(b.style.height=e[1]+"px");return e}for(var j=0,k=h=0,m=0,f=!0,g=!0;d--;)e=a(c[d]),j=Math.max(j,e[0]),h=Math.max(h,e[1]),k+=e[0],m+=e[1],f=f&&0<e[0],g=g&&0<e[1];c=j;d=b.elmFlowDirection;"X"===d&&(c=f?k:0);"Y"===d&&(h=g?m:0);0<c&&(b.style.width=c+"px");0<h&&(b.style.height=h+"px");return[c,h]},h=function(){var b=document.getElementById("content");a(b.children[0])};return{initialize:function(){d=ElmCode.main();+d.hasOwnProperty("recv")||(d=Elm.Input(d));document.getElementById("content").appendChild(d.value);h();var a=document.getElementById("widthChecker").offsetWidth;a!==window.innerWidth&&Dispatcher.notify(Window.dimensions.id,Value.Tuple(a,window.innerHeight));d=Elm.Lift(function(a){var b=document.getElementById("content"),c=b.children[0];b.replaceChild(a,c);delete c;h();return a},[d])},notify:function(a,d){c+=1;for(var h=b.length;h--;)b[h].recv(c,a,d)},adjust:h,inputs:b}}(),Signal=function(){function d(a){for(var b=+["Nil"],c=a.length;c--;)b=["Cons",a[c],b];return b}var c=function(){return document.addEventListener?function(a,b,c){a.addEventListener(b,c,!1)}:function(a,b,c){a.attachEvent("on"+b,c)}}(),b=function(){function a(b){var c=0,d=0;b||(b=window.event);if(b.pageX||b.pageY)c=b.pageX,d=b.pageY;else if(b.clientX||b.clientY)c=b.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,d=b.clientY+document.body.scrollTop+document.documentElement.scrollTop;return Value.Tuple(c,d)}var b=Elm.Input(Value.Tuple(0,+0)),d=Elm.Input(!1),m=Elm.Input(!1),f=Elm.Input(Value.Tuple());c(document,"click",function(){Dispatcher.notify(m.id,!0);Dispatcher.notify(f.id,Value.Tuple());Dispatcher.notify(m.id,!1)});c(document,"mousedown",function(){Dispatcher.notify(d.id,!0)});c(document,"mouseup",function(){Dispatcher.notify(d.id,!1)});c(document,"mousemove",function(c){Dispatcher.notify(b.id,a(c))});return{position:b,x:Elm.Lift(function(a){return a[1]},[b]),y:Elm.Lift(function(a){return a[2]},[b]),isClicked:m,isDown:d,clicks:f}}(),+a=function(){return{every:function(a){var a=1E3*a,b=Elm.Input(0),c=0;setInterval(function(){c+=a;Dispatcher.notify(b.id,c/1E3)},a);return b},after:function(a){var a=1E3*a,b=Elm.Input(!1);setTimeout(function(){Dispatcher.notify(b.id,!0)},a);return b},before:function(a){var a=1E3*a,b=Elm.Input(!0);setTimeout(function(){Dispatcher.notify(b.id,!1)},a);return b}}}(),h=function(){var a=Elm.Input(Value.Tuple(window.innerWidth,window.innerHeight));c(window,"resize",function(){var b=document.getElementById("widthChecker").offsetWidth;+Dispatcher.notify(a.id,Value.Tuple(b,window.innerHeight))});return{dimensions:a,width:Elm.Lift(function(a){return a[1]},[a]),height:Elm.Lift(function(a){return a[2]},[a])}}(),i={Raw:function(){function a(b,c){return"Nil"===c[0]?c:c[1]===b?c[2]:["Cons",c[1],a(b,c[2])]}var b=Elm.Input(["Nil"]),d=Elm.Input(["Nothing"]);c(document,"keydown",function(a){var c;a:{for(c=b.value;"Nil"!==c[0];){if(c[1]===a.keyCode){c=!0;break a}c=c[2]}c=!1}c||Dispatcher.notify(b.id,["Cons",a.keyCode,b.value])});c(document,+"keyup",function(c){c=a(c.keyCode,b.value);Dispatcher.notify(b.id,c)});c(window,"blur",function(){Dispatcher.notify(b.id,["Nil"])});c(document,"keypress",function(a){Dispatcher.notify(d.id,["Just",a.charCode||a.keyCode]);Dispatcher.notify(d.id,["Nothing"])});return{keysDown:b,charPressed:d}}()},l=function(){var a=function(a){return function(b){var c=Elm.Input(["Waiting"]),e={};window.XMLHttpRequest?e=new XMLHttpRequest:window.ActiveXObject&&(e=new ActiveXObject("Microsoft.XMLHTTP"));e.onreadystatechange=+function(){4===e.readyState&&Dispatcher.notify(c.id,200===e.status?["Success",d(e.responseText)]:["Failure",e.status,d(e.statusText)])};e.open(a,Data.String.toText(b),!0);e.send(null);return c}},b=function(a){return function(b){var c=Elm.Input(["Nothing"]),b=Elm.Lift(function(b){if("Just"!==b[0]){try{Dispatcher.notify(c.id,["Nothing"])}catch(e){}return[]}try{Dispatcher.notify(c.id,["Just",["Waiting"]])}catch(m){c.value=["Just",["Waiting"]]}var j={};window.XMLHttpRequest?j=new XMLHttpRequest:window.ActiveXObject&&+(j=new ActiveXObject("Microsoft.XMLHTTP"));j.onreadystatechange=function(){4===j.readyState&&Dispatcher.notify(c.id,["Just",200===j.status?["Success",d(j.responseText)]:["Failure",j.status,d(j.statusText)]])};j.open(a,Data.String.toText(b[1]),!0);j.send(null);return[]},[b]);return Elm.Lift(function(a){return function(){return a}},[c,b])}};return{get:a("GET"),post:a("POST"),gets:b("GET"),posts:b("POST")}}(),n=function(){return{inRange:function(a){return function(b){return Elm.Input(Math.floor(Math.random()*+(b-a+1))+a)}},randomize:function(a){return function(b){return function(c){return Elm.Lift(function(){return Math.floor(Math.random()*(b-a+1))+a},[c])}}}}}(),o=function(){var a=function(a){a.isElmLeaf=!0;var b=Elm.Input(["Nil"]);c(a,"keyup",function(){Dispatcher.notify(b.id,d(a.value));a.focus()});return Value.Tuple(a,b)},b=function(a){a=document.createElement(a);a.id=Guid.guid();return a},h=function(a){for(var d=b("select"),e=[];"Cons"===a[0];){var h=b("option"),k=Text.toText(a[1][1]);h.value=k;h.innerHTML=+k;d.appendChild(h);e.push(a[1][2]);a=a[2]}var i=Elm.Input(e[0]);c(d,"change",function(){Dispatcher.notify(i.id,e[d.selectedIndex])});return Value.Tuple(d,i)};return{textArea:function(c){return function(d){var g=b("textarea");g.rows=d;g.cols=c;return a(g,"")}},textField:function(c){var d=b("input");d.type="text";return a(d,c)},password:function(c){var d=b("input");d.type="password";return a(d,c)},checkbox:function(a){var d=b("input");d.type="checkbox";d.checked=a;var e=Elm.Input(a);c(d,"change",function(){Dispatcher.notify(e.id,+d.checked)});return Value.Tuple(d,e)},dropDown:h,stringDropDown:function(a){return h(List.map(function(a){return Value.Tuple(a,a)})(a))},button:function(a){var d=b("input");d.type="button";d.value=Text.toText(a);var e=Elm.Input(!1);c(d,"click",function(){Dispatcher.notify(e.id,!0);Dispatcher.notify(e.id,!1)});return Value.Tuple(d,e)}}}();return{addListener:c,Mouse:b,Keyboard:i,Time:a,Window:h,HTTP:l,Random:n,Input:o,constant:function(a){return Elm.Input(a)},lift:function(a){return function(b){return Elm.Lift(a,+[b])}},lift2:function(a){return function(b){return function(c){return Elm.Lift(a,[b,c])}}},lift3:function(a){return function(b){return function(c){return function(d){return Elm.Lift(a,[b,c,d])}}}},lift4:function(a){return function(b){return function(c){return function(d){return function(f){return Elm.Lift(a,[b,c,d,f])}}}}},foldp:function(a){return function(b){return function(c){return Elm.Fold(a,b,c)}}},count:function(a){return Elm.Fold(function(){return function(a){return a+1}},0,a)},keepIf:Elm.keepIf,+dropIf:Elm.dropIf,keepWhen:Elm.keepWhen,dropWhen:Elm.dropWhen,dropRepeats:Elm.dropRepeats,sampleOn:Elm.sampleOn}}(),Prelude=function(){var d=function(c){return function(b){var a=c%b,a=0==c?0:0<b?0<=c?a:a+b:-d(-c)(-b);return a==b?0:a}};return{id:function(c){return c},not:function(c){return!c},fst:function(c){return c[1]},snd:function(c){return c[2]},rem:function(c){return function(b){return c%b}},sqrt:Math.sqrt,abs:Math.abs,pi:Math.PI,sin:Math.sin,cos:Math.cos,tan:Math.tan,asin:Math.asin,acos:Math.acos,+atan:Math.atan,mod:d,min:function(c){return function(b){return Math.min(c,b)}},max:function(c){return function(b){return Math.max(c,b)}},flip:function(c){return function(b){return function(a){return c(a)(b)}}},clamp:function(c){return function(b){return function(a){return Math.min(b,Math.max(c,a))}}},curry:function(c){return function(b){return function(a){return c(["Tuple2",b,a])}}},uncurry:function(c){return function(b){if("Tuple2"!==b[0])throw"Function was uncurry'd but was not given a pair.";return c(b[1])(b[2])}},+logBase:function(c){return function(b){return Math.log(b)/Math.log(c)}},Just:Data.Maybe.Just,Nothing:Data.Maybe.Nothing,maybe:Data.Maybe.maybe,map:Data.List.map,filter:Data.List.filter,head:Data.List.head,tail:Data.List.tail,last:Data.List.last,length:Data.List.length,reverse:Data.List.reverse,foldr:Data.List.foldr,foldr1:Data.List.foldr1,foldl:Data.List.foldl,foldl1:Data.List.foldl1,and:Data.List.and,or:Data.List.or,forall:Data.List.forall,exists:Data.List.exists,sum:Data.List.sum,product:Data.List.product,+concat:Data.List.concat,concatMap:Data.List.concatMap,maximum:Data.List.maximum,minimum:Data.List.minimum,scanl:Data.List.scanl,scanl1:Data.List.scanl1,take:Data.List.take,drop:Data.List.drop,lift:Signal.lift,lift2:Signal.lift2,lift3:Signal.lift3,lift4:Signal.lift4,foldp:Signal.foldp,constant:Signal.constant,count:Signal.count,keepIf:Signal.keepIf,dropIf:Signal.dropIf,keepWhen:Signal.keepWhen,dropWhen:Signal.dropWhen,dropRepeats:Signal.dropRepeats,sampleOn:Signal.sampleOn}}(),eq=Value.eq;+Signal.addListener(document,"elm_log",function(d){console.log(d.value)});Signal.addListener(document,"elm_title",function(d){document.title=d.value});Signal.addListener(document,"elm_redirect",function(d){0<d.value.length&&(window.location=d.value)});var includeGlobal=this;+(function(){var d=function(b){for(var a in b)if("Internal"!==a)try{includeGlobal[a]=b[a]}catch(c){"length"===a&&(includeGlobal.execScript("var length;"),length=b[a])}},c=function(b){return function(a){includeGlobal[b]=includeGlobal[b]||{};for(var c in a)"Internal"!==c&&(includeGlobal[b][c]=a[c])}};d(Element);d(Text);color=Element.color;height=Element.height;show=Value.show;d(Color);d(Shape);d(Line);c("Time")(Signal.Time);c("Mouse")(Signal.Mouse);c("Keyboard")(Signal.Keyboard);c("Window")(Signal.Window);+c("HTTP")(Signal.HTTP);c("Input")(Signal.Input);c("Random")(Signal.Random)})();var ElmCode={};ElmCode.Data=Data;ElmCode.Signal=Signal;ElmCode.Data.List=List;ElmCode.Foreign=Foreign;ElmCode.Prelude=Prelude;
src/Ast.hs view
@@ -6,7 +6,7 @@ import Types
 import Guid
 
-data Module = Module [String] Exports Imports Defs
+data Module = Module [String] Exports Imports Defs JSFFI
 
 type Exports = [String]
 
@@ -14,6 +14,9 @@ data ImportMethod = As String | Hiding [String] | Importing [String]
 
 type Defs = [(String,Expr)]
+
+type JSFFI = ( [(String, Expr, String, Type)]
+             , [(String, String, Type)] )
 
 
 data Pattern = PData String [Pattern] | PVar String | PAnything
src/Compiler.hs view
@@ -20,38 +20,41 @@         , runtime :: Maybe FilePath         , separate_js :: Bool         , only_js :: Bool---        , verbose_js :: Bool+        , import_js :: [FilePath]+        , generate_noscript :: Bool         }     deriving (Data,Typeable,Show,Eq)  elm = ELM { make = False &= help "automatically compile dependencies."           , files = def &= args &= typ "FILES"-          , runtime = Nothing &= typ "FILE" &=+          , runtime = Nothing &= typFile &=             help "Specify a custom location for Elm's runtime system."           , separate_js = False &= help "Compile to separate HTML and JS files."           , only_js = False &= help "Compile only to JavaScript."---          , verbose_js = False &= help "Produce JavaScript that may be easier to debug."+          , import_js = [] &= typFile &= help "Include a JavaScript file before the body of the Elm program. Can be used many times. Files will be included in the given order."+          , generate_noscript = False &= help "Add generated <noscript> tag to HTML output."           } &=     help "Compile Elm programs to HTML, CSS, and JavaScript." &=-    summary "The Elm Compiler v0.3.0, (c) Evan Czaplicki"+    summary "The Elm Compiler v0.3.5, (c) Evan Czaplicki"  main = do   args <- cmdArgs elm-  mini <- getDataFileName "elm-runtime-0.3.0.js"+  mini <- getDataFileName "elm-runtime-0.3.5.js"   compileArgs mini args -compileArgs mini (ELM _ [] _ _ _) =+compileArgs mini (ELM _ [] _ _ _ _ _) =     putStrLn "Usage: elm [OPTIONS] [FILES]\nFor more help: elm --help"-compileArgs mini (ELM make files rtLoc split only) =-    mapM_ (fileTo get what $ fromMaybe mini rtLoc) files+compileArgs mini (ELM make files rtLoc split only js nscrpt) =+    mapM_ (fileTo get what js nscrpt $ fromMaybe mini rtLoc) files         where get = if make then getModules [] else getModule               what = if only then JS else                          if split then Split else HTML  data What = JS | HTML | Split -fileTo get what rtLoc file = do+fileTo get what jsFiles noscript rtLoc file = do   ems <- get file+  jss <- concat `fmap` mapM readFile jsFiles   case ems of     Left err -> putStrLn $ "Error while compiling " ++ file ++ ":\n" ++ err     Right ms ->@@ -59,18 +62,18 @@             js = name ++ ".js"             html = name ++ ".html"         in  case what of-              JS -> writeFile js $ concatMap jsModule ms-              HTML -> writeFile html . renderHtml $ modulesToHtml rtLoc ms+              JS -> writeFile js $ jss ++ concatMap jsModule ms+              HTML -> writeFile html . renderHtml $ modulesToHtml "" rtLoc jss noscript ms               Split -> do                   writeFile html . renderHtml $ linkedHtml rtLoc js ms-                  writeFile js $ concatMap jsModule ms+                  writeFile js $ jss ++ concatMap jsModule ms  getModules :: [String] -> FilePath -> IO (Either String [Module]) getModules uses file = do   code <- readFile file   case initialize code of     Left err -> return . Left $ "Error in " ++ file ++ ":\n" ++ err-    Right modul@(Module _ _ imports _) ->+    Right modul@(Module _ _ imports _ _) ->         let imps = filter (`notElem` builtInModules) $ map fst imports in         case intersect uses imps of           x:_ -> return . Left $ "Error: Cyclic dependency. Module " ++
src/Gen/CompileToJS.hs view
@@ -14,9 +14,9 @@ showErr err = mainEquals $ "text(monospace(" ++ msg ++ "))"     where msg = show . concatMap (++"<br>") . lines $ err -parens = ("("++) . (++")")-braces = ("{"++) . (++"}")-jsList = ("["++) . (++"]") . intercalate ","+parens s  = "(" ++ s ++ ")"+braces s  = "{" ++ s ++ "}"+jsList ss = "["++ intercalate "," ss ++"]" jsFunc args body = "function(" ++ args ++ "){" ++ body ++ "}" assign x e = "\nvar " ++ x ++ "=" ++ e ++ ";" ret e = "\nreturn "++ e ++";"@@ -38,12 +38,15 @@            ]  -jsModule (Module names exports imports defs) =+jsModule (Module names exports imports defs foreigns) =     tryBlock (tail modNames) $ concat-                 [ concatMap (\n -> globalAssign n $ n ++ " || {}") . map (intercalate ".") . drop 2 . inits $ take (length modNames - 1) modNames-                 , "\nif (" ++ modName ++ ") throw \"Module name collision, '" ++ intercalate "." (tail modNames) ++ "' is already defined.\"; "-                 , globalAssign modName $ jsFunc "" (includes ++ body ++ export) ++ "()"-                 , mainEquals $ modName ++ ".main" ]+           [ concatMap (\n -> globalAssign n $ n ++ " || {}") .+             map (intercalate ".") . drop 2 . inits $+             take (length modNames - 1) modNames+           , "\nif (" ++ modName ++ ") throw \"Module name collision, '" +++             intercalate "." (tail modNames) ++ "' is already defined.\"; "+           , globalAssign modName $ jsFunc "" (includes++ims++body++exs++export)++"()"+           , mainEquals $ modName ++ ".main" ]         where modNames = if null names then ["ElmCode", "Main"] else "ElmCode" : names               modName  = intercalate "." modNames               includes = concatMap jsImport $@@ -54,12 +57,27 @@               getNames (x,_) =                   let y = reverse . tail . dropWhile isDigit $ reverse x in                   if y `elem` exps then Just $ y ++ ":" ++ x else Nothing+              (ims,exs) = let (i,e) = foreigns in+                          (concatMap importEvent i, concatMap exportEvent e) +importEvent (js,base,elm,_) =+    concat [ "\nvar " ++ elm ++ " = Elm.Input(" ++ toJS base ++ ");"+           , "\nSignal.addListener(document, '" ++ js+           , "', function(e) { Dispatcher.notify(" ++ elm+           , ".id, e.value); });" ]+exportEvent (js,elm,_) =+    concat [ "\nlift(function(v) { var e = document.createEvent('Event');"+           , "e.initEvent('" ++ js ++ "', true, true);"+           , "e.value = v;"+           , "document.dispatchEvent(e); return v; })(" ++ elm ++ ");"+           ]+ jsImport (modul, how) =-  concat [ "\ntry{" ++ modul ++ "} catch(e) {throw \"Module '"+  concat [ "\ntry{" ++ modul ++ " instanceof Object} catch(e) {throw \"Module '"          , drop 1 (dropWhile (/='.') modul)          , "' is missing. Compile with --make flag or load missing "-         , "module in a separate JavaScript file.\";}" ] ++ jsImport' (modul, how)+         , "module in a separate JavaScript file.\";}" ] +++     jsImport' (modul, how)    jsImport' (modul, As name) = assign name modul jsImport' (modul, Importing []) = jsImport' (modul, Hiding [])@@ -78,7 +96,7 @@       Number n -> show n       Var x -> x       Chr c -> show c-      Str s -> toJS . list $ map Chr s+      Str s -> "Value.str" ++ parens (show s)       Boolean b -> if b then "true" else "false"       Range lo hi -> jsRange (toJS lo) (toJS hi)       Access e lbl -> toJS e ++ "." ++ lbl@@ -140,6 +158,6 @@                     "." -> jsFunc "x" . ret $ e1 ++ parens (e2 ++ parens "x")                     "==" -> "eq(" ++ e1 ++ "," ++ e2 ++ ")"                     "/=" -> "not(eq(" ++ e1 ++ "," ++ e2 ++ "))"-                    _ -> e1 ++ (o:p) ++ e2+                    _ -> parens (e1 ++ (o:p) ++ e2)  append e1 e2 = "Value.append" ++ parens (e1 ++ "," ++ e2)
src/Gen/ExtractNoscript.hs view
@@ -3,7 +3,7 @@ 
 import Ast
 
-extract (Module _ _ _ defs) =
+extract (Module _ _ _ defs _) =
     concatMap (\s -> "<p>" ++ s ++ "</p>") $ concatMap (extract' . snd) defs
 
 extract' expr =
src/Gen/GenerateHtml.hs view
@@ -17,14 +17,16 @@ import ExtractNoscript  css = H.style ! A.type_ "text/css" $ preEscapedToMarkup-      ("* { padding:0; margin:0; \-       \hyphens: auto; -moz-hyphens: auto;\-       \ -webkit-hyphens: auto; -ms-hyphens: auto; }\+      ("html,head,body { padding:0; margin:0; }\        \body { font-family: Arial; }\        \a:link {text-decoration: none}\        \a:visited {text-decoration: none}\        \a:active {text-decoration: none}\        \a:hover {text-decoration: underline; color: #ff8f12;}" :: String)+{--+       \hyphens: auto; -moz-hyphens: auto;\+       \ -webkit-hyphens: auto; -ms-hyphens: auto; }\+--}  makeScript :: Either String String -> H.Html makeScript (Left s) =@@ -44,17 +46,21 @@ generateHtml libLoc title source =     case initialize source of       Left err -> createHtml libLoc title (Right $ showErr err) (H.noscript "")-      Right modul -> modulesToHtml libLoc [modul]+      Right modul -> modulesToHtml title libLoc [] False [modul]  -modulesToHtml libLoc modules = createHtml libLoc title js noscript-    where title = (\(Module names _ _ _) -> intercalate "." names) $ last modules-          js = Right $ concatMap jsModule modules-          noscript = extract $ last modules+modulesToHtml title libLoc jss nscrpt modules = createHtml libLoc title' js noscript+    where js = Right $ jss ++ concatMap jsModule modules+          noscript = if nscrpt then extract $ last modules else ""+          title' = if null title then altTitle else title+          altTitle = (\(Module names _ _ _ _) -> intercalate "." names) $+                     last modules+                    linkedHtml rtLoc jsLoc modules =     createHtml rtLoc title (Left jsLoc) (H.noscript "")-    where title = (\(Module names _ _ _) -> intercalate "." names) $ last modules+    where title = (\(Module names _ _ _ _) -> intercalate "." names) $+                  last modules   createHtml libLoc title js noscript =
src/Initialize.hs view
@@ -1,6 +1,7 @@ module Initialize (initialize) where  import Control.Monad.Error+import Data.List (lookup)  import Ast import Parser (parseProgram)@@ -9,10 +10,23 @@ import Rename import Optimize + initialize str = do-  (Module name ex im defs, tipes) <- parseProgram str-  let expr = rename . Let defs $ Var "_"-  subs <- unify (liftM2 (++) hints tipes) expr-  let Let defs' _ = optimize expr-  let im' = if any ((=="Prelude") . fst) im then im else ("Prelude", Importing []):im-  return (subs `seq` Module name ex im' defs')+  (Module name ex im defs (ims,exs), tipes) <- parseProgram str+  let (Let ds _) = rename . Let defs $ Var "_"+  let dict n = maybe n id . lookup n $ zip (map fst defs) (map fst ds)+  let allHints = liftM2 (\a b -> a ++ b ++ ffiHints (ims,exs)) hints tipes+  subs <- unify allHints . Let ds $ checkFFI dict ims exs+  let Let defs' _ = optimize (Let ds $ Var "_")+  let im' = if any ((=="Prelude") . fst) im then im else+                ("Prelude", Importing []):im+  let exs' = map (\(js,n,t) -> (js,dict n,t)) exs+  return (subs `seq` Module name ex im' defs' (ims,exs'))+++ffiHints (ims,exs) =+    map (\(_,_,n,t) -> (n,t)) ims ++ map (\(_,n,t) -> (n,t)) exs++checkFFI dict ims exs = list $ ims' ++ exs'+  where ims' = map (\(_,b,n,_)-> Binop "==" (Var n) (App (Var "constant") b)) ims+        exs' = map (\(_,n,_)  -> Binop "==" (Var n) (Var $ dict n)) exs
src/Parse/ParseExpr.hs view
@@ -1,4 +1,4 @@-module ParseExpr (def) where
+module ParseExpr (def,term) where
 
 import Ast
 import Control.Applicative ((<$>), (<*>))
+ src/Parse/ParseForeign.hs view
@@ -0,0 +1,67 @@+
+module ParseForeign (foreignDefs) where
+
+import Control.Applicative ((<$>), (<*>))
+import Data.Either (partitionEithers)
+import Text.Parsec hiding (newline,spaces)
+
+import Ast
+import ParseLib
+import ParseExpr (term)
+import ParseTypes
+import Types (signalOf)
+
+
+foreignDefs = do
+  f  <- foreign --commitIf (reserved "foreign") foreign
+  fs <- many (commitIf (freshLine >> reserved "foreign") (freshLine >> foreign))
+  return . partitionEithers $ f:fs
+
+
+foreign = do try (reserved "foreign") ; whitespace
+             Left <$> importEvent <|> Right <$> exportEvent
+
+exportEvent = do
+  try (reserved "export" >> whitespace >> reserved "jsevent" >> whitespace)
+  js   <- jsVar    ; whitespace
+  elm  <- lowVar   ; whitespace
+  string "::"      ; whitespace
+  tipe <- typeExpr
+  case tipe of
+    ADTPT "Signal" [pt] ->
+        either fail (return . (,,) js elm . signalOf) (toForeignType pt)
+    _ -> fail "When exporting events, the exported value must be a Signal."
+
+importEvent = do
+  try (reserved "import" >> whitespace >> reserved "jsevent" >> whitespace)
+  js   <- jsVar ; whitespace
+  base <- term <?> "Base case for imported signal (signals cannot be undefined)"
+  whitespace
+  elm  <- lowVar <?> "Name of imported signal"
+  whitespace ; string "::" ; whitespace
+  tipe <- typeExpr
+  case tipe of
+    ADTPT "Signal" [pt] ->
+        either fail (return . (,,,) js base elm . signalOf) (toForeignType pt)
+    _ -> fail "When importing events, the imported value must be a Signal."
+
+
+jsVar :: (Monad m) => ParsecT [Char] u m String
+jsVar = betwixt '"' '"' $ do
+  v <- (:) <$> (letter <|> char '_') <*> many (alphaNum <|> char '_')
+  if v `notElem` jsReserveds then return v else
+      fail $ "'" ++ v ++
+          "' is not a good name for a importing or exporting JS values."
+
+jsReserveds =
+    [ "null", "undefined", "Nan", "Infinity", "true", "false", "eval"
+    , "arguments", "int", "byte", "char", "goto", "long", "final", "float"
+    , "short", "double", "native", "throws", "boolean", "abstract", "volatile"
+    , "transient", "synchronized", "function", "break", "case", "catch"
+    , "continue", "debugger", "default", "delete", "do", "else", "finally"
+    , "for", "function", "if", "in", "instanceof", "new", "return", "switch"
+    , "this", "throw", "try", "typeof", "var", "void", "while", "with", "class"
+    , "const", "enum", "export", "extends", "import", "super", "implements"
+    , "interface", "let", "package", "private", "protected", "public"
+    , "static", "yield"
+    ]
src/Parse/ParseLib.hs view
@@ -11,7 +11,8 @@             , "case", "of", "data"             , "let", "in"             , "module", "where"-            , "import", "as", "hiding" ]+            , "import", "as", "hiding"+            , "export", "foreign" ]  expecting = flip (<?>) 
src/Parse/ParseTypes.hs view
@@ -81,3 +81,22 @@                                       "Char" -> CharT                                       "Bool" -> BoolT                                       _ -> ADT x []++toForeignType (LambdaPT t1 t2) =+    fail $ "Elm's JavaScript event interface does not yet handle functions. " +++           "Only simple values can be imported and exported in this release."+    --LambdaT <$> toForeignType t1 <*> toForeignType t2+toForeignType (ADTPT name args)+    | isJsStructure name =  ADT name <$> mapM toForeignType args+    | otherwise =+        Left $ "'" ++ name ++ "' is not an exportable type " +++               "constructor. Only 'JSArray' and 'JSTupleN' are exportable."++toForeignType (VarPT x@(c:_))+    | isLower c =+        Left "All exported types must be concrete types (JSNumber, JSString, etc.)"+    | x `elem` ["JSString","JSNumber","JSElement","JSBool"] = Right (ADT x [])+    | otherwise = Left $ "'" ++ x ++ "' is not an exportable type. Only JSTypes are exportable."++isJsStructure name = name == "JSArray" || isTuple+    where isTuple = "JSTuple" == take 7 name && drop 7 name `elem` map show [2..5]
src/Parse/Parser.hs view
@@ -11,6 +11,7 @@ import ParseExpr
 import ParseTypes
 import ParseModules
+import ParseForeign
 
 
 freshDef = commitIf (freshLine >> (letter <|> char '_')) $ do
@@ -26,12 +27,13 @@ 
 program = do
   optional freshLine
-  (names,exports) <- option ([],[]) (moduleDef `followedBy` freshLine)
+  (names,exports) <- option (["Main"],[]) (moduleDef `followedBy` freshLine)
   is <- (do try (lookAhead $ reserved "import")
             imports `followedBy` freshLine) <|> return []
+  jsffi <- foreignDefs `followedBy` freshLine <|> return ([],[])
   (vs,es,ts) <- defs
   optional freshLine ; optional spaces ; eof
-  return (Module names exports is $ zip vs es, zip vs `liftM` ts)
+  return (Module names exports is (zip vs es) jsffi, zip vs `liftM` ts)
 
 parseProgram source = 
     case parse program "" source of
src/Types/Hints.hs view
@@ -49,6 +49,35 @@          ] ++ hasType (IntT ==> IntT ==> point ==> shape) ["ngon","rect","oval"]
 
 
+--------  Foreign  --------
+
+casts =
+  [ "castJSBoolToBool"       -: jsBool ==> BoolT
+  , "castBoolToJSBool"       -: BoolT ==> jsBool
+  , "castJSNumberToInt"      -: jsNumber ==> IntT
+  , "castIntToJSNumber"      -: IntT ==> jsNumber
+  , "castJSElementToElement" -: IntT ==> IntT ==> jsElement ==> element
+  , "castElementToJSElement" -: element ==> jsElement
+  , "castJSStringToString"   -: jsString ==> string
+  , "castStringToJSString"   -: string ==> jsString
+  --  , "castJSNumberToFloat -: 
+  --  , "castFloatToJSNumber -:
+  ]
+
+polyCasts = sequence
+  [ do a <- var     ; "castJSArrayToList"   -:: jsArray a ==> listOf a
+  , do a <- var     ; "castListToJSArray"   -:: listOf a ==> jsArray a
+  , do vs <- vars 2 ; "castTupleToJSTuple2" -:: tupleOf vs ==> jsTuple vs
+  , do vs <- vars 3 ; "castTupleToJSTuple3" -:: tupleOf vs ==> jsTuple vs
+  , do vs <- vars 4 ; "castTupleToJSTuple4" -:: tupleOf vs ==> jsTuple vs
+  , do vs <- vars 5 ; "castTupleToJSTuple5" -:: tupleOf vs ==> jsTuple vs
+  , do vs <- vars 2 ; "castJSTupleToTuple2" -:: jsTuple vs ==> tupleOf vs
+  , do vs <- vars 3 ; "castJSTupleToTuple3" -:: jsTuple vs ==> tupleOf vs
+  , do vs <- vars 4 ; "castJSTupleToTuple4" -:: jsTuple vs ==> tupleOf vs
+  , do vs <- vars 5 ; "castJSTupleToTuple5" -:: jsTuple vs ==> tupleOf vs
+  ]
+
+
 --------  Signals  --------
 
 sig ts = fn ts ==> fn (map signalOf ts)
@@ -62,22 +91,36 @@     , do ts <- vars 5 ; "lift4"    -:: sig ts
     , do [a,b] <- vars 2 
          "foldp" -:: (a ==> b ==> b) ==> b ==> signalOf a ==> signalOf b
+    , do a <- var ; "randomize" -:: IntT ==> IntT ==> signalOf a ==> signalOf IntT
+    , do a <- var ; "count"     -:: signalOf a ==> signalOf IntT
+    , do a <- var ; "keepIf"    -:: (a==>BoolT) ==> a ==> signalOf a ==> signalOf a
+    , do a <- var ; "dropIf"    -:: (a==>BoolT) ==> a ==> signalOf a ==> signalOf a
+    , do a <- var ; "keepWhen"  -:: signalOf BoolT ==>a==> signalOf a ==> signalOf a
+    , do a <- var ; "dropWhen"  -:: signalOf BoolT ==>a==> signalOf a ==> signalOf a
+    , do a <- var ; "dropRepeats" -:: signalOf a ==> signalOf a
+    , do [a,b] <- vars 2 ; "sampleOn" -:: signalOf a ==> signalOf b ==> signalOf b
     ]
 
-concreteSignals =
-    [ "Mouse.position"    -: signalOf point
-    , "Mouse.x"           -: signalOf IntT
-    , "Mouse.y"           -: signalOf IntT
-    , "Mouse.isDown"      -: signalOf BoolT
-    , "Mouse.isClicked"   -: signalOf BoolT
-    , "Window.dimensions" -: signalOf point
-    , "Window.width"      -: signalOf IntT
-    , "Window.height"     -: signalOf IntT
-    , "Input.textField"   -: string ==> tupleOf [element, signalOf string]
-    , "Input.password"    -: string ==> tupleOf [element, signalOf string]
-    , "Input.textArea"    -: IntT ==> IntT ==> tupleOf [element, signalOf string]
-    , "Input.stringDropDown" -: listOf string ==> tupleOf [element, signalOf string]
-    ]
+concreteSignals = 
+  [ "keysDown"    -: signalOf (listOf IntT)
+  , "charPressed" -: signalOf (maybeOf IntT)
+  , "inRange"     -: IntT ==> IntT ==> signalOf IntT
+  , "every"       -: time ==> signalOf time
+  , "before"      -: time ==> signalOf BoolT
+  , "after"       -: time ==> signalOf BoolT
+  , "dimensions"  -: signalOf point
+  , "position"    -: signalOf point
+  , "x"           -: signalOf IntT
+  , "y"           -: signalOf IntT
+  , "isDown"      -: signalOf BoolT
+  , "isClicked"   -: signalOf BoolT
+  , "textField"   -: string ==> tupleOf [element, signalOf string]
+  , "password"    -: string ==> tupleOf [element, signalOf string]
+  , "textArea"    -: IntT ==> IntT ==> tupleOf [element, signalOf string]
+  , "checkBox"    -: BoolT ==> tupleOf [element, signalOf BoolT]
+  , "button"      -: string ==> tupleOf [element, signalOf BoolT]
+  , "stringDropDown" -: listOf string ==> tupleOf [element, signalOf string]
+  ]
 
 --------  Math and Binops  --------
 
@@ -111,7 +154,7 @@     , do [a,b,c] <- vars 3 ; "."    -:: (b ==> c) ==> (a ==> b) ==> (a ==> c)
     , do [a,b] <- vars 2   ; "$"    -:: (a ==> b) ==> a ==> b
     , do a <- var ; ":"       -:: a ==> listOf a ==> listOf a
-    , do a <- var ; "++"      -:: listOf a ==> listOf a ==> listOf a
+    , do a <- var ; "++"      -:: a ==> a ==> a
     , do a <- var ; "Cons"    -:: a ==> listOf a ==> listOf a 
     , do a <- var ; "Nil"     -:: listOf a
     , do a <- var ; "Just"    -:: a ==> ADT "Maybe" [a]
@@ -121,7 +164,7 @@ 
 ints = map (-: (listOf IntT ==> IntT)) [ "sum","product","maximum","minimum" ]
 
-lists = liftM (map (first ("List."++)) . (++ints)) . sequence $
+lists = liftM (++ints) . sequence $
     [ "and"  -:: listOf BoolT ==> BoolT
     , "or"   -:: listOf BoolT ==> BoolT
     , "sort" -:: listOf IntT ==> listOf IntT
@@ -136,6 +179,9 @@     , do a <- var ; "exists"  -:: (a ==> BoolT) ==> listOf a ==> BoolT
     , do a <- var ; "concat"  -:: listOf (listOf a) ==> listOf a
     , do a <- var ; "reverse" -:: listOf a ==> listOf a
+    , do a <- var ; "take"    -:: IntT ==> listOf a ==> listOf a
+    , do a <- var ; "drop"    -:: IntT ==> listOf a ==> listOf a
+    , do a <- var ; "partition"    -:: (a==>BoolT)==>listOf a==>tupleOf [listOf a,listOf a]
     , do a <- var ; "intersperse"  -:: a ==> listOf a ==> listOf a
     , do a <- var ; "intercalate"  -:: listOf a ==> listOf(listOf a) ==> listOf a
     , do [a,b] <- vars 2 ; "zip"   -:: listOf a ==>listOf b ==>listOf(tupleOf [a,b])
@@ -152,8 +198,8 @@ --------  Everything  --------
 
 hints = do
-  fs <- funcs ; ls <- lists ; ss <- signals
+  fs <- funcs ; ls <- lists ; ss <- signals ; pcasts <- polyCasts
   return $ concat [ fs, ls, ss, math, bool, str2elem, textAttrs
                   , elements, directions, colors, lineTypes, shapes
-                  , concreteSignals
+                  , concreteSignals, casts, pcasts
                   ]
src/Types/Types.hs view
@@ -30,7 +30,16 @@ listOf t   = ADT "List" [t]
 signalOf t = ADT "Signal" [t]
 tupleOf ts = ADT ("Tuple" ++ show (length ts)) ts
+maybeOf t  = ADT "Maybe" [t]
 string     = listOf CharT
+time       = IntT
+
+jsBool     = ADT "JSBool" []
+jsNumber   = ADT "JSNumber" []
+jsString   = ADT "JSString" []
+jsElement  = ADT "JSElement" []
+jsArray t  = ADT "JSArray" [t]
+jsTuple ts = ADT ("JSTuple" ++ show (length ts)) ts
 
 infixr ==>
 t1 ==> t2 = LambdaT t1 t2