on d9d1dfd help sign in
elk/core-js/Automaton.js
221 lines 8.2 kB history raw
2(function() {
3try{
5var $op={};
6for(this['i'] in Elm){eval('var '+this['i']+'=Elm[this.i];');}
7if (Elm.Automaton) throw new Error("Module name collision, 'Automaton' is already defined.");
8Elm.Automaton=function(){
9 try{
10 if (!(Elm.Prelude instanceof Object)) throw 'module not found';
11 } catch(e) {
12 throw ("Module 'Prelude' is missing. Compile with --make flag or load missing module in a separate JavaScript file.");
13 }
14 var hiddenVars={};
15 for (this['i'] in Elm.Prelude) {
16 if (hiddenVars[this['i']]) continue;
17 eval('var ' + this['i'] + ' = Elm.Prelude[this.i];');}
18 function Automaton_0(a1){
19 return ["Automaton",a1];}
20 var Listen_8=["Listen"];
21 var Ignore_9=["Ignore"];
22 function DragFrom_10(a1){
23 return ["DragFrom",a1];}
24 $op['>>>'] = function(a1_24){
25 return function(a2_25){
26 return function(){
27 var Automaton$m1_26=a1_24;
28 var m1_27=function(){
29 switch(Automaton$m1_26[0]){
30 case "Automaton":
31 return Automaton$m1_26[1];
32 }
33 throw new Error("Non-exhaustive pattern match in case");}();
34 var Automaton$m2_28=a2_25;
35 var m2_29=function(){
36 switch(Automaton$m2_28[0]){
37 case "Automaton":
38 return Automaton$m2_28[1];
39 }
40 throw new Error("Non-exhaustive pattern match in case");}();
41 return Automaton_0(function(a_32){
42 return function(){
43 var Tuple2$bm1__33=m1_27(a_32);
44 var b_34=function(){
45 switch(Tuple2$bm1__33[0]){
46 case "Tuple2":
47 return Tuple2$bm1__33[1];
48 }
49 throw new Error("Non-exhaustive pattern match in case");}();
50 var m1__35=function(){
51 switch(Tuple2$bm1__33[0]){
52 case "Tuple2":
53 return Tuple2$bm1__33[2];
54 }
55 throw new Error("Non-exhaustive pattern match in case");}();
56 return function(){
57 var Tuple2$cm2__40=m2_29(b_34);
58 var c_41=function(){
59 switch(Tuple2$cm2__40[0]){
60 case "Tuple2":
61 return Tuple2$cm2__40[1];
62 }
63 throw new Error("Non-exhaustive pattern match in case");}();
64 var m2__42=function(){
65 switch(Tuple2$cm2__40[0]){
66 case "Tuple2":
67 return Tuple2$cm2__40[2];
68 }
69 throw new Error("Non-exhaustive pattern match in case");}();
70 return ["Tuple2",c_41,$op['>>>'](m1__35)(m2__42)];}();}();});}();};};
71 $op['<<<'] = function(a2_47){
72 return function(a1_48){
73 return $op['>>>'](a1_48)(a2_47);};};
74 $op['^>>'] = function(f_49){
75 return function(a_50){
76 return $op['>>>'](pure_4(f_49))(a_50);};};
77 $op['>>^'] = function(a_51){
78 return function(f_52){
79 return $op['>>>'](a_51)(pure_4(f_52));};};
80 $op['^<<'] = function(f_53){
81 return function(a_54){
82 return $op['>>>'](a_54)(pure_4(f_53));};};
83 $op['<<^'] = function(a_55){
84 return function(f_56){
85 return $op['>>>'](pure_4(f_56))(a_55);};};
86 var count_7=init_5(0)(function(__84){
87 return function(c_85){
88 return (1+c_85);};});
89 function run_1(Automaton$m0_14){
90 return function(input_15){
91 return function(){
92 switch(Automaton$m0_14[0]){
93 case "Automaton":
94 return lift(fst)(foldp$(function(a_17){
95 return function(Tuple2$bAutomaton$m_18){
96 return function(){
97 switch(Tuple2$bAutomaton$m_18[0]){
98 case "Tuple2":
99 switch(Tuple2$bAutomaton$m_18[2][0]){
100 case "Automaton":
101 return Tuple2$bAutomaton$m_18[2][1](a_17);
102 }break;
103 }
104 throw new Error("Non-exhaustive pattern match in case");}();};})(Automaton$m0_14[1])(input_15));
105 }
106 throw new Error("Non-exhaustive pattern match in case");}();};}
107 function step_2(Automaton$m_21){
108 return function(a_22){
109 return function(){
110 switch(Automaton$m_21[0]){
111 case "Automaton":
112 return Automaton$m_21[1](a_22);
113 }
114 throw new Error("Non-exhaustive pattern match in case");}();};}
115 function combine_3(autos_57){
116 return Automaton_0(function(a_58){
117 return function(){
118 var Tuple2$bsautos__59=unzip(map(function(Automaton$m_62){
119 return function(){
120 switch(Automaton$m_62[0]){
121 case "Automaton":
122 return Automaton$m_62[1](a_58);
123 }
124 throw new Error("Non-exhaustive pattern match in case");}();})(autos_57));
125 var bs_60=function(){
126 switch(Tuple2$bsautos__59[0]){
127 case "Tuple2":
128 return Tuple2$bsautos__59[1];
129 }
130 throw new Error("Non-exhaustive pattern match in case");}();
131 var autos__61=function(){
132 switch(Tuple2$bsautos__59[0]){
133 case "Tuple2":
134 return Tuple2$bsautos__59[2];
135 }
136 throw new Error("Non-exhaustive pattern match in case");}();
137 return ["Tuple2",bs_60,combine_3(autos__61)];}();});}
138 function pure_4(f_68){
139 return Automaton_0(function(x_69){
140 return ["Tuple2",f_68(x_69),pure_4(f_68)];});}
141 function init_5(s_70){
142 return function(step_71){
143 return Automaton_0(function(a_72){
144 return function(){
145 var s__73=step_71(a_72)(s_70);
146 return ["Tuple2",s__73,init_5(s__73)(step_71)];}();});};}
147 function init__6(s_74){
148 return function(step_75){
149 return Automaton_0(function(a_76){
150 return function(){
151 var Tuple2$bs__77=step_75(a_76)(s_74);
152 var b_78=function(){
153 switch(Tuple2$bs__77[0]){
154 case "Tuple2":
155 return Tuple2$bs__77[1];
156 }
157 throw new Error("Non-exhaustive pattern match in case");}();
158 var s__79=function(){
159 switch(Tuple2$bs__77[0]){
160 case "Tuple2":
161 return Tuple2$bs__77[2];
162 }
163 throw new Error("Non-exhaustive pattern match in case");}();
164 return ["Tuple2",b_78,init__6(s__79)(step_75)];}();});};}
165 function vecSub_11(Tuple2$x1y1_86){
166 return function(Tuple2$x2y2_87){
167 return function(){
168 switch(Tuple2$x1y1_86[0]){
169 case "Tuple2":
170 return function(){
171 switch(Tuple2$x2y2_87[0]){
172 case "Tuple2":
173 return ["Tuple2",(Tuple2$x1y1_86[1]-Tuple2$x2y2_87[1]),(Tuple2$x1y1_86[2]-Tuple2$x2y2_87[2])];
174 }
175 throw new Error("Non-exhaustive pattern match in case");}();
176 }
177 throw new Error("Non-exhaustive pattern match in case");}();};}
178 function stepDrag_12(Tuple2$presspos_92){
179 return function(Tuple2$dsform_93){
180 return function(){
181 switch(Tuple2$presspos_92[0]){
182 case "Tuple2":
183 return function(){
184 switch(Tuple2$dsform_93[0]){
185 case "Tuple2":
186 return function(){
187 function wrap_98(ds__99){
188 return ["Tuple2",Tuple2$dsform_93[2],["Tuple2",ds__99,Tuple2$dsform_93[2]]];}
189 return function(){
190 switch(Tuple2$dsform_93[1][0]){
191 case "DragFrom":
192 return (Tuple2$presspos_92[1]?["Tuple2",uncurry(move)(vecSub_11(Tuple2$presspos_92[2])(Tuple2$dsform_93[1][1]))(Tuple2$dsform_93[2]),["Tuple2",DragFrom_10(Tuple2$dsform_93[1][1]),Tuple2$dsform_93[2]]]:function(){
193 var form__101=uncurry(move)(vecSub_11(Tuple2$presspos_92[2])(Tuple2$dsform_93[1][1]))(Tuple2$dsform_93[2]);
194 return ["Tuple2",form__101,["Tuple2",Listen_8,form__101]];}());
195 case "Ignore":
196 return wrap_98((Tuple2$presspos_92[1]?Ignore_9:Listen_8));
197 case "Listen":
198 return wrap_98((not(Tuple2$presspos_92[1])?Listen_8:(isWithin(Tuple2$presspos_92[2])(Tuple2$dsform_93[2])?DragFrom_10(Tuple2$presspos_92[2]):Ignore_9)));
199 }
200 throw new Error("Non-exhaustive pattern match in case");}();}();
201 }
202 throw new Error("Non-exhaustive pattern match in case");}();
203 }
204 throw new Error("Non-exhaustive pattern match in case");}();};}
205 function draggable_13(form_102){
206 return init__6(["Tuple2",Listen_8,form_102])(stepDrag_12);}
207 return {$op : {'>>>' : $op['>>>'], '<<<' : $op['<<<'], '^>>' : $op['^>>'], '>>^' : $op['>>^'], '^<<' : $op['^<<'], '<<^' : $op['<<^']},
208 run:run_1,
209 step:step_2,
210 combine:combine_3,
211 pure:pure_4,
212 init:init_5,
213 init$:init__6,
214 count:count_7,
215 draggable:draggable_13};}();
216Elm.main=function(){
217 return Elm.Automaton.main;};
218} catch (e) {
219Elm.main=function() {
220var msg = ('<br/><h2>Your browser may not be supported. Are you using a modern browser?</h2>' + '<br/><span style="color:grey">Runtime Error in Automaton module:<br/>' + e + '</span>');
221document.body.innerHTML = Elm.Text.monospace(msg);throw e;};}}());