on master help sign in
Correct the frequent misspelling of "Foreign" (such a weird word!) and change internal representation of foreign import/export information.
commit6cffa48e4eca9f0d036c12c1a71a89b40d3b31f0 authorevancz <info@elm-lang.org> dateMon 25 Jun 2012, 07:07 (14 years ago) parent86f5ce0
10 files changed+122−68
core-js/foriegn/JavaScript.js → core-js/foreign/JavaScript.js+1−1 elm-mini.js+54−50 elm/Elm.cabal+5−3 elm/src/Ast.hs+6−1 elm/src/Gen/CompileToJS.hs+24−6 elm/src/Gen/ExtractNoscript.hs+1−1 elm/src/Initialize.hs+13−4 elm/src/Parse/ParseExpr.hs+1−1 elm/src/Parse/ParseTypes.hs+13 elm/src/Parse/Parser.hs+4−1
core-js/foriegn/JavaScript.js → core-js/foreign/JavaScript.jsrenamed+1−1
@@ -1,5 +1,5 @@
11
2−var Foriegn = function() {
2+var Foreign = function() {
33 var JavaScript = function() {
44 function castJSNumberToFloat(n) { return n; }
55 function castFloatToJSNumber(n) { return n; }
elm-mini.js+54−50
@@ -1,50 +1,54 @@
1−var Guid=function(){var b=0;return{guid:function(){return b+=1}}}(),Value=function(){var b=function(a){a.replace('"',"&#34;");a.replace("&","&#38;");a.replace("'","&#39;");a.replace("<","&#60;");a.replace(">","&#62;");return a},c=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 b="",g=a.length;--g;)b=","+c(a[g])+b;","===b[0]&&(b=b.substring(1));return"("+b+")"}if("Cons"===a[0])for(var g="string"===typeof a[1]?'"':"]",
2−f="string"===typeof a[1]?"":",",b=("string"===typeof a[1]?'"':"[")+c(a[1]),a=a[2];;)if("Cons"===a[0])b+=f+c(a[1]),a=a[2];else return b+g;else{if("Nil"===a[0])return"[]";b="";for(g=a.length;--g;)b=" "+c(a[g])+b;b=a[0]+b;return 1<a.length?"("+b+")":b}}return a+""};return{show:function(a){return Text.monospace(b(c(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);
3−if("Nil"===a[0])return b;for(var c=["Cons",a[1],["Nil"]],f=c,a=a[2];"Cons"===a[0];)f[2]=["Cons",a[1],["Nil"]],a=a[2],f=f[2];f[2]=b;return c},toText:function(a){if("string"===typeof a)return a;for(var c=[];"Cons"===a[0];)c.push(a[1]),a=a[2];return b(c.join(""))},properEscape:b}}(),List=function(){function b(a){return function(e){if("Nil"===e[0])return e;"Cons"!==e[0]&&i();for(var b=["Cons",a(e[1]),["Nil"]],d=b,e=e[2];"Cons"===e[0];)d[2]=["Cons",a(e[1]),["Nil"]],e=e[2],d=d[2];return b}}function c(e){return function(a){return function(b){var d=
4−a;if("Nil"===b[0])return d;for("Cons"!==b[0]&&i();"Cons"===b[0];)d=e(b[1])(d),b=b[2];return d}}}function a(e){return function(a){return function(b){var d=a;if("Nil"===b[0])return d;"Cons"!==b[0]&&i();for(var c=[];"Cons"===b[0];)c.push(b[1]),b=b[2];for(b=c.length;b--;)d=e(c[b])(d);return d}}}function h(e){return function(a){var b;"Cons"!==a[0]?b=void 0:(b=a[1],a=a[2],b=c(e)(b)(a));return b}}function g(e){return function(a){return function(b){if("Nil"===b[0])return["Cons",a,["Nil"]];"Cons"!==b[0]&&
5−i();for(var d=[a];"Cons"===b[0];)a=e(b[1])(a),d.push(a),b=b[2];for(var b=["Nil"],c=d.length;c--;)b=["Cons",d[c],b];return b}}}function f(a){return function(e){return function(){for(var b=[function(a){return"Nil"!==a[0]?void 0:["Tuple2",["Nil"],["Nil"]]},function(e){if("Cons"===e[0]){var b=e[1],e=e[2];var d=f(a)(e);"Tuple2"!==d[0]?b=void 0:(e=d[1],d=d[2],b=a(b)?["Tuple2",["Cons",b,e],d]:["Tuple2",e,["Cons",b,d]]);return b}}],d=b.length;d--;){var c=b[d](e);if(void 0!==c)return c}}()}}function j(e){return function(){for(var a=
6−[function(e){return"Nil"!==e[0]?void 0:["Tuple2",["Nil"],["Nil"]]},function(e){if("Cons"!==e[0])e=void 0;else if(e=["Tuple2",e[1],j(e[2])],"Tuple2"!==e[0]||"Tuple2"!==e[1][0])e=void 0;else var a=e[1][1],b=e[1][2],e="Tuple2"!==e[2][0]?void 0:["Tuple2",["Cons",a,e[2][1]],["Cons",b,e[2][2]]];return e}],b=a.length;b--;){var d=a[b](e);if(void 0!==d)return d}}()}function l(e){return function(a){return function(){for(var b=[function(e){return"Nil"!==e[0]?void 0:["Nil"]},function(e){if("Cons"===e[0]){var a=
7−e[1];return"Nil"!==e[2][0]?void 0:["Cons",a,["Nil"]]}},function(a){if("Cons"===a[0]){var b=a[1];if("Cons"===a[2][0]){var d=a[2][1],a=a[2][2];return["Cons",b,["Cons",e,l(e)(["Cons",d,a])]]}}}],d=b.length;d--;){var c=b[d](a);if(void 0!==c)return c}}()}}function o(e){return function(a){return function(){for(var b=[function(e){return"Nil"!==e[0]?void 0:["Nil"]},function(e){if("Cons"===e[0]){var a=e[1];return"Nil"!==e[2][0]?void 0:a}},function(a){if("Cons"===a[0]){var b=a[1];if("Cons"===a[2][0]){var d=
8−a[2][1],a=a[2][2];return Value.append(b,Value.append(e,o(e)(["Cons",d,a])))}}}],d=b.length;d--;){var c=b[d](a);if(void 0!==c)return c}}()}}var i=function(){throw"Function expecting a list!";},k=c(function(e){return function(a){return["Cons",e,a]}})(["Nil"]),m=a(function(e){return function(a){return Value.append(e,a)}})(["Nil"]),n=c(function(e){return function(a){return e&&a}})(!0),e=c(function(e){return function(a){return e||a}})(!1),d=c(function(e){return function(a){return e+a}})(0),p=c(function(e){return function(a){return e*
9−a}})(1),r=h(function(e){return function(a){return Math.max(e,a)}}),t=h(function(e){return function(a){return Math.min(e,a)}});return{head:function(e){if("Cons"!==e[0])throw"Error: 'head' only accepts lists of length greater than one.";return e[1]},tail:function(e){if("Cons"!==e[0])throw"Error: 'tail' only accepts lists of length greater than one.";return e[2]},map:b,foldl:c,foldr:a,foldl1:h,foldr1:function(e){return function(b){var d;"Cons"!==b[0]?d=void 0:(d=b[1],b=b[2],d=a(e)(d)(b));return d}},
10−scanl:g,scanl1:function(e){return function(a){if("Cons"!==a[0])throw"Error: 'scanl1' requires a list of at least length 1.";return g(e)(a[1])(a[2])}},filter:function(e){return function(a){if("Nil"===a[0])return a;"Cons"!==a[0]&&i();for(var b=[];"Cons"===a[0];)e(a[1])&&b.push(a[1]),a=a[2];for(var a=["Nil"],d=b.length;d--;)a=["Cons",b[d],a];return a}},length:function(e){for(var a=0;"Cons"===e[0];)a+=1,e=e[2];return a},reverse:k,concat:m,concatMap:function(e){return function(a){return m(b(e)(a))}},and:n,
11−or:e,forall:function(e){return c(function(a){return function(b){return b&&e(a)}})(!0)},exists:function(e){return c(function(a){return function(b){return b||e(a)}})(!1)},sum:d,product:p,maximum:r,minimum:t,partition:f,zipWith:function(e){return function(a){return function(b){if("Nil"===a[0]||"Nil"===b[0])return a;("Cons"!==a[0]||"Cons"!==b[0])&&i();for(var d=[];"Cons"===a[0]&&"Cons"===b[0];)d.push(e(a[1])(b[1])),a=a[2],b=b[2];for(var b=["Nil"],c=d.length;c--;)b=["Cons",d[c],b];return b}}},zip:function(e){return function(a){if("Nil"===
12−e[0]||"Nil"===a[0])return e;("Cons"!==e[0]||"Cons"!==a[0])&&i();for(var b=[];"Cons"===e[0]&&"Cons"===a[0];)b.push(["Tuple2",e[1],a[1]]),e=e[2],a=a[2];for(var a=["Nil"],d=b.length;d--;)a=["Cons",b[d],a];return a}},unzip:j,intersperse:l,intercalate:o,sort:function(a){if("Nil"===a[0])return a;"Cons"!==a[0]&&i();for(var e=[];"Cons"===a[0];)e.push(a[1]),a=a[2];e.sort(function(a,e){return a-e});for(var a=["Nil"],b=e.length;b--;)a=["Cons",e[b],a];return a}}}(),Data=function(){var b=function(){return{fromCode:function(a){return String.fromCharCode(a)},
13−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()}}}(),c=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{catMaybes:List.foldr(a)(["Nil"]),isJust:function(a){return"Just"===
14−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"])}}}();return{String:{toText:Value.toText,properEscape:Value.properEscape},Char:b,Maybe:c,List:List}}(),Color=function(){var b=function(b,a,h,g){return{r:Math.round(255*b),g:Math.round(255*a),b:Math.round(255*h),a:g}};return{black:b(0,0,0,1),white:b(1,1,1,1),red:b(1,0,0,1),green:b(0,1,0,1),blue:b(0,0,1,1),rgba:function(c){return function(a){return function(h){return function(g){return b(c,
15−a,h,g)}}}},rgb:function(c){return function(a){return function(h){return b(c,a,h,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 b=function(a){a=document.createElement(a);a.id=Guid.guid();return a},c=function(a){var d=b("div");d.appendChild(a);return d},a=function(a){return function(d){return function(c){var f=b("div");f.isElmLeaf=!0;f.isElmText=!0;f.innerHTML=c;f.style.textAlign=d;0<a&&(f.style.width=
16−a+"px");return f}}},h=a(0)("left"),g=a(0)("justify"),f=a(0)("center"),j=a(0)("right"),l=function(a){return"DIV"===a.tagName?a:c(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,c){for(var f=b("div"),i=c.length;i--;){var g=d(c[i]);f.appendChild(g)}f.elmFlowDirection=a;return f},m=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 k("Y",l,
17−c);if(1==b)return k("X",o,c);if(2==b)return k("Z",i,c)}},n=function(b){return function(d){if("A"===d.tagName)return n(b)(d.firstChild),d;if(d.hasOwnProperty("isElmText")){var c=a(b)(d.style.textAlign)(d.innerHTML);d.style.height=c.style.height}d.style.width=b+"px";return d}};return{text:h,image:function(a){var d=b("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+
18−"px");Dispatcher.adjust()};d.src=Data.String.toText(a);d.name=d.src;return d},fittedImage:function(a){return function(d){return function(c){var f=b("canvas");f.style.width=a+"px";f.style.height=d+"px";f.width=a;f.height=d;f.innerHTML="Your browser does not support the canvas element.";f.isElmLeaf=!0;var i=b("img");i.onload=function(){if(f.getContext){var b=f.getContext("2d"),c=0,g=0,h=this.width,k=this.height;a/d>this.width/this.height?(k=this.width*d/a,g=(this.height-k)/2):(h=this.height*a/d,c=(this.width-
19−h)/2);b.drawImage(i,c,g,h,k,0,0,f.width,f.height)}};i.src=Data.String.toText(c);return f}}},video:function(a){var a=Data.String.toText(a),d=b("video");d.controls="controls";var c=b("source");c.src=a;c.type="video/"+a.substring(a.length-3,a.length);d.appendChild(c);d.isElmLeaf=!0;return d},audio:function(a){var a=Data.String.toString(a),d=b("video");d.controls="controls";var c=b("source");c.src=a;c.type="audio/"+a.substring(a.length-3,a.length);d.appendChild(c);d.isElmLeaf=!0;return d},collage:function(a){return function(d){return function(c){var f=
20−b("canvas");f.style.width=a+"px";f.style.height=d+"px";f.width=a;f.height=d;if(f.getContext){var i=f.getContext("2d");for(i.clearRect(0,0,f.width,f.height);"Cons"===c[0];)i=c[1](i),c=c[2];return f}f.innerHTML="Your browser does not support the canvas element.";f.isElmLeaf=!0;return f}}},flow:m,layers:m(2),rectangle:function(a){return function(d){var c=b("div");c.isElmLeaf=!0;c.style.width=a+"px";c.style.height=d+"px";return c}},beside:function(a){return function(b){return m(4)(["Cons",a,["Cons",b,
21−["Nil"]]])}},above:function(a){return function(b){return m(3)(["Cons",a,["Cons",b,["Nil"]]])}},below:function(a){return function(b){return m(0)(["Cons",a,["Cons",b,["Nil"]]])}},box:function(a){return function(d){d.style.position="absolute";d.style.margin="auto";var c=(a-1)%3,f=(a-1)/3;2>c&&(d.style.left=0);0<c&&(d.style.right=0);2>f&&(d.style.top=0);0<f&&(d.style.bottom=0);c=b("div");c.style.position="relative";c.appendChild(d);return c}},width:n,height:function(a){return function(b){("A"===b.tagName?
22−b.firstChild:b).style.height=a+"px";return b}},size:function(a){return function(b){return function(c){var f="A"===c.tagName?c.firstChild:c;f.style.width=a+"px";f.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 f=b("a");f.href=Text.fromString(a);f.appendChild(d);return c(f)}},asText:function(b){return a(0)("left")(Value.show(b))},
23−plainText:function(b){return a(0)("left")(Data.String.toText(b))},justifiedText:g,centeredText:f,rightedText:j,up:0,left:1,inward:2,down:3,right:4,outward:5,correctTextSize:function(a){var c=a.style.width?a.style.width.slice(0,-2):0,f=b("div");f.innerHTML=a.innerHTML;f.style.textAlign=a.style.textAlign;0<c&&(f.style.width=c+"px");f.style.visibility="hidden";f.style.styleFloat="left";f.style.cssFloat="left";document.body.appendChild(f);var i=window.getComputedStyle(f);0>=c&&(a.style.width=i.getPropertyValue("width"));
24−a.style.height=i.getPropertyValue("height");document.body.removeChild(f)}}}(),Text=function(){var b=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+">"+b+"</"+a+">"}},a=function(a,b){return function(c){return"<span style='"+a+":"+b+"'>"+c+"</span>"}},h=c("h1"),g=a("font-style","italic"),c=c("b"),f=a("text-decoration","underline"),j=a("text-decoration","overline"),l=
25−a("text-decoration","line-through");return{fromString:b,toText:b,header:h,height:function(b){return a("font-size",b+"em")},italic:g,bold:c,underline:f,overline:j,strikeThrough:l,monospace:a("font-family","monospace"),color:function(b){return a("color",Color.Internal.extract(b))},link:function(a){return function(c){return"<a href='"+b(a)+"'>"+c+"</a>"}}}}(),Shape=function(){var b=function(a,b,c,f){return{center:a,points:b,theta:c,scale:f}},c=function(a){return function(b){return function(c){return function(f){f.save();
26−f.translate(c.center[0],c.center[1]);f.rotate(c.theta);f.scale(c.scale,c.scale);f.beginPath();var j=c.points;f.moveTo(j[0][0],j[0][1]);for(var l=j.length;l--;)f.lineTo(j[l][0],j[l][1]);f.closePath();a?(f.fillStyle=Color.Internal.extract(b),f.fill()):(f.strokeStyle=Color.Internal.extract(b),f.stroke());f.restore();return f}}}};return{polygon:function(a){return function(c){for(var g=[];"Cons"===a[0];)g.push([a[1][1],a[1][2]]),a=a[2];c=[c[1],c[2]];return b(c,g,0,1)}},ngon:function(a){return function(c){return function(g){for(var f=
27−[],j=a;j--;)f.push([c*Math.cos(2*Math.PI*j/a),c*Math.sin(2*Math.PI*j/a)]);g=[g[1],g[2]];return b(g,f,0,1)}}},rect:function(a){return function(c){return function(g){var f=[[-a/2,-c/2],[a/2,-c/2],[a/2,c/2],[-a/2,c/2]],g=[g[1],g[2]];return b(g,f,0,1)}}},oval:function(a){return function(c){return function(g){for(var f=[],j=2*Math.PI;0<j;j-=Math.PI/50)f.push([a/2*Math.cos(j),c/2*Math.sin(j)]);g=[g[1],g[2]];return b(g,f,0,1)}}},move:function(a){return function(c){return function(g){return b([a+g.center[0],
28−c+g.center[1]],g.points,g.theta,g.scale)}}},rotate:function(a){return function(c){return b(c.center,c.points,c.theta+2*Math.PI*a,c.scale)}},scale:function(a){return function(c){return b(c.center,c.points,c.theta,c.scale*a)}},filled:c(!0),outlined:c(!1),customOutline:function(a){return function(b){return function(c){c.points.push(c.points[0]);return Line.customLine(a)(b)(c)}}}}}(),Line=function(){var b=function(b){return function(a){return function(h){if("string"===typeof b[0]){for(var g=[];"Cons"===
29−b[0];)g.push(b[1]),b=b[2];b=g}0===b.length&&(b=[8,4]);return function(f){f.save();f.beginPath();f.translate(h.center[0],h.center[1]);f.rotate(h.theta);f.scale(h.scale,h.scale);var g=b,l=h.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);
30−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:b,solid:function(b){return function(a){return function(h){h.save();h.beginPath();h.translate(a.center[0],a.center[1]);h.rotate(a.theta);h.scale(a.scale,a.scale);var g=a.points,f=g.length;for(h.moveTo(g[f-1][0],g[f-1][1]);f--;)h.lineTo(g[f][0],g[f][1]);h.strokeStyle=Color.Internal.extract(b);
31−h.stroke();h.restore();return h}}},dashed:b([8,4]),dotted:b([3,3])}}(),Elm=function(){var b=function(a,b,c){for(var h=a.length;h--;)a[h].recv(b,c)},c=function(a){this.id=Guid.guid();this.value=a;this.kids=[];this.recv=function(a,c,g){if(c=c===this.id)this.value=g;b(this.kids,a,c)};Dispatcher.inputs.push(this)},a=function(a,c){this.id=Guid.guid();this.value=null;this.kids=[];this.inbox={};c.reverse();this.recalc=function(){for(var b=a,h=c.length;h--;)b=b(c[h].value);this.value=b};this.recalc();this.recv=
32−function(a,g){this.inbox.hasOwnProperty(a)||(this.inbox[a]={changed:!1,count:0});var i=this.inbox[a];i.count+=1;g&&(i.changed=!0);i.count==c.length&&(i.changed&&this.recalc(),b(this.kids,a,i.changed),delete this.inbox[a])};for(var h=c.length;h--;)c[h].kids.push(this)},h=function(a,c,h){this.id=Guid.guid();this.value=c;this.kids=[];this.recv=function(c,f){f&&(this.value=a(h.value)(this.value));b(this.kids,c,f)};h.kids.push(this)};return{Input:function(a){return new c(a)},Lift:function(b,c){return new a(b,
33−c)},Fold:function(a,b,c){return new h(a,b,c)}}}(),Dispatcher=function(){var b=null,c=0,a=[],h=function(a){var b=a.childNodes,c=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===c){var i=h(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=
34−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;c--;)i=h(b[c]),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;c=a.elmFlowDirection;"X"===c&&(b=e?m:0);"Y"===c&&(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");h(a.children[0])};return{initialize:function(){var a=ElmCode.hasOwnProperty("main")?ElmCode.main:main;try{b=a()}catch(c){throw c;}b.hasOwnProperty("recv")||
35−(b=Elm.Input(b));document.getElementById("content").appendChild(b.value);g();a=document.getElementById("widthChecker").offsetWidth;a!==window.innerWidth&&Dispatcher.notify(Window.dimensions.id,Value.Tuple(a,window.innerHeight));b=Elm.Lift(function(a){var b=document.getElementById("content"),c=b.children[0];b.replaceChild(a,c);delete c;g();return a},[b])},notify:function(b,g){c+=1;for(var h=a.length;h--;)a[h].recv(c,b,g)},adjust:g,inputs:a}}(),Signal=function(){function b(a){for(var b=["Nil"],c=a.length;c--;)b=
36−["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)}}(),a=function(){function a(b){var c=0,f=0;b||(b=window.event);if(b.pageX||b.pageY)c=b.pageX,f=b.pageY;else if(b.clientX||b.clientY)c=b.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,f=b.clientY+document.body.scrollTop+document.documentElement.scrollTop;return Value.Tuple(c,f)}var b=Elm.Input(Value.Tuple(0,0)),f=Elm.Input(!1),
37−g=Elm.Input(!1);c(document,"click",function(){Dispatcher.notify(g.id,!0);Dispatcher.notify(g.id,!1)});c(document,"mousedown",function(){Dispatcher.notify(f.id,!0)});c(document,"mouseup",function(){Dispatcher.notify(f.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:g,isDown:f,clickedOn:function(a){var b=Elm.Input(!1);c(a,"click",function(){Dispatcher.notify(b.id,
38−!0);Dispatcher.notify(b.id,!1)});return Value.Tuple(a,b)}}}(),h=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));
39−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])}}(),f={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"]),f=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;
40−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(f.id,["Just",a.charCode||a.keyCode]);Dispatcher.notify(f.id,["Nothing"])});return{keysDown:b,charPressed:f}}()},j=function(){var a=function(a){return function(c){var e=Elm.Input(["Waiting"]),d={};window.XMLHttpRequest?d=new XMLHttpRequest:
41−window.ActiveXObject&&(d=new ActiveXObject("Microsoft.XMLHTTP"));d.onreadystatechange=function(){4===d.readyState&&Dispatcher.notify(e.id,200===d.status?["Success",b(d.responseText)]:["Failure",d.status,b(d.statusText)])};d.open(a,Data.String.toText(c),!0);d.send(null);return e}},c=function(a){return function(c){var e=Elm.Input(["Nothing"]),c=Elm.Lift(function(c){if("Just"!==c[0]){try{Dispatcher.notify(e.id,["Nothing"])}catch(f){}return[]}try{Dispatcher.notify(e.id,["Just",["Waiting"]])}catch(g){e.value=
42−["Just",["Waiting"]]}var h={};window.XMLHttpRequest?h=new XMLHttpRequest:window.ActiveXObject&&(h=new ActiveXObject("Microsoft.XMLHTTP"));h.onreadystatechange=function(){4===h.readyState&&Dispatcher.notify(e.id,["Just",200===h.status?["Success",b(h.responseText)]:["Failure",h.status,b(h.statusText)]])};h.open(a,Data.String.toText(c[1]),!0);h.send(null);return[]},[c]);return Elm.Lift(function(a){return function(){return a}},[e,c])}};return{get:a("GET"),post:a("POST"),gets:c("GET"),posts:c("POST")}}(),
43−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 e=Elm.Input(["Nil"]);c(a,"keyup",function(){Dispatcher.notify(e.id,b(a.value));a.focus()});return Value.Tuple(a,e)},f=function(a){a=document.createElement(a);a.id=Guid.guid();return a},g=function(a){for(var b=
44−f("select"),d=[];"Cons"===a[0];){var g=f("option"),h=Text.toText(a[1][1]);g.value=h;g.innerHTML=h;b.appendChild(g);d.push(a[1][2]);a=a[2]}var i=Elm.Input(d[0]);c(b,"change",function(){Dispatcher.notify(i.id,d[b.selectedIndex])});return Value.Tuple(b,i)};return{textArea:function(b){return function(c){var d=f("textarea");d.rows=c;d.cols=b;return a(d,"")}},textField:function(b){var c=f("input");c.type="text";return a(c,b)},password:function(b){var c=f("input");c.type="password";return a(c,b)},checkbox:function(a){var b=
45−f("input");b.type="checkbox";b.checked=a;var d=Elm.Input(a);c(b,"change",function(){Dispatcher.notify(d.id,b.checked)});return Value.Tuple(b,d)},dropDown:g,stringDropDown:function(a){return g(List.map(function(a){return Value.Tuple(a,a)})(a))},button:function(a){var b=f("input");b.type="button";b.value=Text.toText(a);var d=Elm.Input(!1);c(b,"click",function(){Dispatcher.notify(d.id,!0);Dispatcher.notify(d.id,!1)});return Value.Tuple(b,d)}}}();return{Mouse:a,Keyboard:f,Time:h,Window:g,HTTP:j,Random:l,
46−Input:o}}(),id=function(b){return b},not=function(b){return!b},sqrt=function(b){return Math.sqrt(b)},rem=function(b){return function(c){return b%c}},mod=function(b){return function(c){var a=b%c,a=0==b?0:0<c?0<=b?a:a+c:-mod(-b)(-c);return a==c?0:a}},abs=function(b){return Math.abs(b)},logBase=function(b){return function(c){return Math.log(c)/Math.log(b)}},min=function(b){return function(c){return Math.min(b,c)}},max=function(b){return function(c){return Math.max(b,c)}},clamp=function(b){return function(c){return function(a){return Math.min(c,
47−Math.max(b,a))}}},sin=Math.sin,cos=Math.cos,tan=Math.tan,asin=Math.asin,acos=Math.acos,atan=Math.atan,flip=function(b){return function(c){return function(a){return b(a)(c)}}},Just=function(b){return["Just",b]},Nothing=["Nothing"],eq=function(b,c){if("object"===typeof b){if(b===c)return!0;if(b.length!==c.length)return!1;for(var a=b.length;a--;)if(!eq(b[a],c[a]))return!1;return!0}return b===c};function constant(b){return Elm.Input(b)}function lift(b){return function(c){return Elm.Lift(b,[c])}}
48−function lift2(b){return function(c){return function(a){return Elm.Lift(b,[c,a])}}}function lift3(b){return function(c){return function(a){return function(h){return Elm.Lift(b,[c,a,h])}}}}function lift4(b){return function(c){return function(a){return function(h){return function(g){return Elm.Lift(b,[c,a,h,g])}}}}}function foldp(b){return function(c){return function(a){return Elm.Fold(b,c,a)}}}var includeGlobal=this;
49−(function(){var b=function(a){for(var b in a)if("Internal"!==b)try{includeGlobal[b]=a[b]}catch(c){"length"===b&&(includeGlobal.execScript("var length;"),length=a[b])}},c=function(a){return function(b){includeGlobal[a]=includeGlobal[a]||{};for(var c in b)"Internal"!==c&&(includeGlobal[a][c]=b[c])}};b(Element);b(Text);color=Element.color;height=Element.height;show=Value.show;c("Time")(Signal.Time);c("Mouse")(Signal.Mouse);c("Keyboard")(Signal.Keyboard);c("Window")(Signal.Window);c("HTTP")(Signal.HTTP);
50−c("Input")(Signal.Input);c("Random")(Signal.Random);b(Color);b(Shape);b(Line)})();var ElmCode={};ElmCode.Data=Data;ElmCode.Signal=Signal;ElmCode.Data.List=List;
1+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]?'"':"]",
2+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);
3+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=
4+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"!==
5+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=
6+[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=
7+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=
8+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=
9+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:
10+(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))}},
11+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];
12+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=
13+["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)},
14+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"===
15+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,
16+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);
17+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,
18+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}};
19+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.";
20+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=
21+!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.";
22+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";
23+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);
24+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;
25+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"<"+
26+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))},
27+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=
28+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,
29+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),
30+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,
31+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();
32+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,
33+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)},
34+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,
35+-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");
36+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=
37+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=
38+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,
39+"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);
40+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]},
41+[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,
42+["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);
43+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)]:
44+["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=
45+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,
46+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,
47+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,
48+[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%
49+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"!==
50+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,
51+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],
52+b[a]))return!1;return!0}return f===b},includeGlobal=this;
53+(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);
54+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/Elm.cabal+5−3
@@ -1,6 +1,6 @@
11
22Name: Elm
3−Version: 0.3.0
3+Version: 0.3.5
44Synopsis: The Elm language module.
55Description: Elm aims to make client-side web-development more pleasant.
66 It is a statically/strongly typed, functional reactive
@@ -21,8 +21,8 @@ Category: Compiler, Language
2121
2222Build-type: Simple
2323
24−Extra-source-files: changelog.md
25−Data-files: elm-runtime-0.3.0.js
24+Extra-source-files: changelog.txt
25+Data-files: elm-runtime-0.3.5.js
2626Cabal-version: >=1.8
2727
2828source-repository head
@@ -48,6 +48,7 @@ Library
4848 ParseExpr,
4949 ParseTypes,
5050 ParseModules,
51+ ParseForeign,
5152 Types,
5253 Constrain,
5354 Hints,
@@ -84,6 +85,7 @@ Executable elm
8485 ParseExpr,
8586 ParseTypes,
8687 ParseModules,
88+ ParseForeign,
8789 Types,
8890 Constrain,
8991 Hints,
elm/src/Ast.hs+6−1
@@ -6,7 +6,7 @@ import Data.List (intercalate)
66import Types
77import Guid
88
9−data Module = Module [String] Exports Imports Defs
9+data Module = Module [String] Exports Imports Defs [JSFFI]
1010
1111type Exports = [String]
1212
@@ -15,6 +15,11 @@ data ImportMethod = As String | Hiding [String] | Importing [String]
1515
1616type Defs = [(String,Expr)]
1717
18+data JSFFI = ImportValue String String Type
19+ | ExportValue String String Type
20+ | ImportEvent String String Expr Type
21+ | ExportEvent String String Type
22+
1823
1924data Pattern = PData String [Pattern] | PVar String | PAnything
2025 deriving (Eq)
elm/src/Gen/CompileToJS.hs+24−6
@@ -38,12 +38,15 @@ tryBlock names e =
3838 ]
3939
4040
41−jsModule (Module names exports imports defs) =
41+jsModule (Module names exports imports defs (ims,exs)) =
4242 tryBlock (tail modNames) $ concat
43− [ concatMap (\n -> globalAssign n $ n ++ " || {}") . map (intercalate ".") . drop 2 . inits $ take (length modNames - 1) modNames
44− , "\nif (" ++ modName ++ ") throw \"Module name collision, '" ++ intercalate "." (tail modNames) ++ "' is already defined.\"; "
45− , globalAssign modName $ jsFunc "" (includes ++ body ++ export) ++ "()"
46− , mainEquals $ modName ++ ".main" ]
43+ [ concatMap (\n -> globalAssign n $ n ++ " || {}") .
44+ map (intercalate ".") . drop 2 . inits $
45+ take (length modNames - 1) modNames
46+ , "\nif (" ++ modName ++ ") throw \"Module name collision, '" ++
47+ intercalate "." (tail modNames) ++ "' is already defined.\"; "
48+ , globalAssign modName $ jsFunc "" (includes++body++export)++"()"
49+ , mainEquals $ modName ++ ".main" ]
4750 where modNames = if null names then ["ElmCode", "Main"] else "ElmCode" : names
4851 modName = intercalate "." modNames
4952 includes = concatMap jsImport $
@@ -55,11 +58,26 @@ jsModule (Module names exports imports defs) =
5558 let y = reverse . tail . dropWhile isDigit $ reverse x in
5659 if y `elem` exps then Just $ y ++ ":" ++ x else Nothing
5760
61+ffi (ImportValue js elm _) = assign elm js
62+ffi (ExportValue js elm _) = assign js elm
63+ffi (ImportEvent js elm base _) =
64+ concat [ "var " ++ elm ++ " = Elm.Input(" ++ toJS base ++ ");"
65+ , "Signal.addListener(document, '" ++ js
66+ , "', function(e) { Dispatcher.notify(" ++ elm
67+ , ".id, e); });" ]
68+ffi (ExportEvent js elm base _) =
69+ concat [ "lift (function(v) { var e = document.createEvent('Event');"
70+ , "e.initEvent('" ++ js ++ "', true, true);"
71+ , "e.elmValue = v;"
72+ , "document.disspatchEvent(e); return v; })(" ++ elm ++ ")"
73+ ]
74+
5875jsImport (modul, how) =
5976 concat [ "\ntry{" ++ modul ++ "} catch(e) {throw \"Module '"
6077 , drop 1 (dropWhile (/='.') modul)
6178 , "' is missing. Compile with --make flag or load missing "
62− , "module in a separate JavaScript file.\";}" ] ++ jsImport' (modul, how)
79+ , "module in a separate JavaScript file.\";}" ] ++
80+ jsImport' (modul, how)
6381
6482jsImport' (modul, As name) = assign name modul
6583jsImport' (modul, Importing []) = jsImport' (modul, Hiding [])
elm/src/Gen/ExtractNoscript.hs+1−1
@@ -3,7 +3,7 @@ module ExtractNoscript (extract) where
33
44import Ast
55
6−extract (Module _ _ _ defs) =
6+extract (Module _ _ _ defs _) =
77 concatMap (\s -> "<p>" ++ s ++ "</p>") $ concatMap (extract' . snd) defs
88
99extract' expr =
elm/src/Initialize.hs+13−4
@@ -10,9 +10,18 @@ import Rename
1010import Optimize
1111
1212initialize str = do
13− (Module name ex im defs, tipes) <- parseProgram str
13+ (Module name ex im defs jsffi, tipes) <- parseProgram str
1414 let expr = rename . Let defs $ Var "_"
15− subs <- unify (liftM2 (++) hints tipes) expr
15+ let allHints = liftM2 (\a b -> a ++ b ++ map ffiHint jsffi) hints tipes
16+ subs <- unify allHints expr
1617 let Let defs' _ = optimize expr
17− let im' = if any ((=="Prelude") . fst) im then im else ("Prelude", Importing []):im
18− return (subs `seq` Module name ex im' defs')
18+ let im' = if any ((=="Prelude") . fst) im then im else
19+ ("Prelude", Importing []):im
20+ return (subs `seq` Module name ex im' defs' jsffi)
21+
22+
23+ffiHint x = case x of
24+ ImportValue _ n t -> (n,t)
25+ ExportValue _ n t -> (n,t)
26+ ImportEvent _ n _ t -> (n,t)
27+ ExportEvent _ n t -> (n,t)
elm/src/Parse/ParseExpr.hs+1−1
@@ -1,4 +1,4 @@
1−module ParseExpr (def) where
1+module ParseExpr (def,term) where
22
33import Ast
44import Control.Applicative ((<$>), (<*>))
elm/src/Parse/ParseTypes.hs+13
@@ -81,3 +81,16 @@ toType pairs outType (name,args) =
8181 "Char" -> CharT
8282 "Bool" -> BoolT
8383 _ -> ADT x []
84+
85+toForiegnType (LambdaPT t1 t2) =
86+ LambdaT <$> toForiegnType t1 <*> toForiegnType t2
87+toForiegnType (ADTPT name args) = do
88+ case name == "JSArray" of
89+ True -> ADT name <$> mapM toForiegnType args
90+ False -> Left $ "'" ++ name ++
91+ "' is not an exportable type constructor. Only 'JSArray' is exportable."
92+toForiegnType (VarPT x@(c:_))
93+ | isLower c =
94+ Left "All exported types must be concrete types (JSNumber, JSString, etc.)"
95+ | x `elem` [ "JSString", "JSNumber", "JSElement" ] = Right (ADT x [])
96+ | otherwise = Left $ "'" ++ x ++ "' is not an exportable type. JSNumber, JSString, JSElement, and (JSArray a) are exportable."
elm/src/Parse/Parser.hs+4−1
@@ -11,6 +11,7 @@ import ParseLib
1111import ParseExpr
1212import ParseTypes
1313import ParseModules
14+import ParseForeign
1415
1516
1617freshDef = commitIf (freshLine >> (letter <|> char '_')) $ do
@@ -29,9 +30,11 @@ program = do
2930 (names,exports) <- option ([],[]) (moduleDef `followedBy` freshLine)
3031 is <- (do try (lookAhead $ reserved "import")
3132 imports `followedBy` freshLine) <|> return []
33+ jsffi <- foreignDefs
34+ freshLine
3235 (vs,es,ts) <- defs
3336 optional freshLine ; optional spaces ; eof
34− return (Module names exports is $ zip vs es, zip vs `liftM` ts)
37+ return (Module names exports is (zip vs es) jsffi, zip vs `liftM` ts)
3538
3639parseProgram source =
3740 case parse program "" source of