2012-10-19 07:13:28 +00:00
try {
for ( var i in Elm ) { this [ i ] = Elm [ i ] ; }
if ( Elm . Automaton ) throw "Module name collision, 'Automaton' is already defined." ;
Elm . Automaton = function ( ) {
try { if ( ! ( Elm . Prelude instanceof Object ) ) throw 'module not found' ; } catch ( e ) { throw "Module 'Prelude' is missing. Compile with --make flag or load missing module in a separate JavaScript file." ; }
var hiddenVars = [ ] ;
for ( var i in Elm . Prelude ) {
if ( hiddenVars . indexOf ( i ) >= 0 ) continue ;
this [ i ] = Elm . Prelude [ i ] ; }
function Automaton _0 ( a1 ) {
return [ "Automaton" , a1 ] ; } ;
var Listen _9 = [ "Listen" ] ;
var Ignore _10 = [ "Ignore" ] ;
function DragFrom _11 ( a1 ) {
return [ "DragFrom" , a1 ] ; } ;
var count _8 = init _6 ( 0 ) ( function ( _ _75 ) {
return function ( c _76 ) {
return ( 1 + c _76 ) ; } ; } ) ;
function run _1 ( Automaton$m0 _15 ) {
return function ( input _16 ) {
return function ( ) {
switch ( Automaton$m0 _15 [ 0 ] ) {
case "Automaton" :
return lift ( fst ) ( foldp _ ( function ( a _18 ) {
return function ( Tuple2$bAutomaton$m _19 ) {
return function ( ) {
switch ( Tuple2$bAutomaton$m _19 [ 0 ] ) {
case "Tuple2" :
switch ( Tuple2$bAutomaton$m _19 [ 2 ] [ 0 ] ) {
case "Automaton" :
return Tuple2$bAutomaton$m _19 [ 2 ] [ 1 ] ( a _18 ) ;
} break ;
}
throw "Non-exhaustive pattern match in case" ; } ( ) ; } ; } ) ( Automaton$m0 _15 [ 1 ] ) ( input _16 ) ) ;
}
throw "Non-exhaustive pattern match in case" ; } ( ) ; } ; } ;
function step _2 ( Automaton$m _22 ) {
return function ( a _23 ) {
return function ( ) {
switch ( Automaton$m _22 [ 0 ] ) {
case "Automaton" :
return Automaton$m _22 [ 1 ] ( a _23 ) ;
}
throw "Non-exhaustive pattern match in case" ; } ( ) ; } ; } ;
function composeAuto _3 ( a1 _25 ) {
return function ( a2 _26 ) {
return function ( ) {
var Automaton$m1 _27 = a1 _25 ;
var m1 _28 = function ( ) {
switch ( Automaton$m1 _27 [ 0 ] ) {
case "Automaton" :
return Automaton$m1 _27 [ 1 ] ;
}
throw "Non-exhaustive pattern match in case" ; } ( ) ;
var Automaton$m2 _29 = a2 _26 ;
var m2 _30 = function ( ) {
switch ( Automaton$m2 _29 [ 0 ] ) {
case "Automaton" :
return Automaton$m2 _29 [ 1 ] ;
}
throw "Non-exhaustive pattern match in case" ; } ( ) ;
return Automaton _0 ( function ( a _33 ) {
return function ( ) {
var Tuple2$bm1 _ _34 = m1 _28 ( a _33 ) ;
var b _35 = function ( ) {
switch ( Tuple2$bm1 _ _34 [ 0 ] ) {
case "Tuple2" :
return Tuple2$bm1 _ _34 [ 1 ] ;
}
throw "Non-exhaustive pattern match in case" ; } ( ) ;
var m1 _ _36 = function ( ) {
switch ( Tuple2$bm1 _ _34 [ 0 ] ) {
case "Tuple2" :
return Tuple2$bm1 _ _34 [ 2 ] ;
}
throw "Non-exhaustive pattern match in case" ; } ( ) ;
return function ( ) {
var Tuple2$cm2 _ _41 = m2 _30 ( b _35 ) ;
var c _42 = function ( ) {
switch ( Tuple2$cm2 _ _41 [ 0 ] ) {
case "Tuple2" :
return Tuple2$cm2 _ _41 [ 1 ] ;
}
throw "Non-exhaustive pattern match in case" ; } ( ) ;
var m2 _ _43 = function ( ) {
switch ( Tuple2$cm2 _ _41 [ 0 ] ) {
case "Tuple2" :
return Tuple2$cm2 _ _41 [ 2 ] ;
}
throw "Non-exhaustive pattern match in case" ; } ( ) ;
return [ "Tuple2" , c _42 , composeAuto _3 ( m1 _ _36 ) ( m2 _ _43 ) ] ; } ( ) ; } ( ) ; } ) ; } ( ) ; } ; } ;
function combine _4 ( autos _48 ) {
return Automaton _0 ( function ( a _49 ) {
return function ( ) {
var Tuple2$bsautos _ _50 = unzip ( map ( function ( Automaton$m _53 ) {
return function ( ) {
switch ( Automaton$m _53 [ 0 ] ) {
case "Automaton" :
return Automaton$m _53 [ 1 ] ( a _49 ) ;
}
throw "Non-exhaustive pattern match in case" ; } ( ) ; } ) ( autos _48 ) ) ;
var bs _51 = function ( ) {
switch ( Tuple2$bsautos _ _50 [ 0 ] ) {
case "Tuple2" :
return Tuple2$bsautos _ _50 [ 1 ] ;
}
throw "Non-exhaustive pattern match in case" ; } ( ) ;
var autos _ _52 = function ( ) {
switch ( Tuple2$bsautos _ _50 [ 0 ] ) {
case "Tuple2" :
return Tuple2$bsautos _ _50 [ 2 ] ;
}
throw "Non-exhaustive pattern match in case" ; } ( ) ;
return [ "Tuple2" , bs _51 , combine _4 ( autos _ _52 ) ] ; } ( ) ; } ) ; } ;
function pure _5 ( f _59 ) {
return Automaton _0 ( function ( x _60 ) {
return [ "Tuple2" , f _59 ( x _60 ) , pure _5 ( f _59 ) ] ; } ) ; } ;
function init _6 ( s _61 ) {
return function ( step _62 ) {
return Automaton _0 ( function ( a _63 ) {
return function ( ) {
var s _ _64 = step _62 ( a _63 ) ( s _61 ) ;
return [ "Tuple2" , s _ _64 , init _6 ( s _ _64 ) ( step _62 ) ] ; } ( ) ; } ) ; } ; } ;
function init _ _7 ( s _65 ) {
return function ( step _66 ) {
return Automaton _0 ( function ( a _67 ) {
return function ( ) {
var Tuple2$bs _ _68 = step _66 ( a _67 ) ( s _65 ) ;
var b _69 = function ( ) {
switch ( Tuple2$bs _ _68 [ 0 ] ) {
case "Tuple2" :
return Tuple2$bs _ _68 [ 1 ] ;
}
throw "Non-exhaustive pattern match in case" ; } ( ) ;
var s _ _70 = function ( ) {
switch ( Tuple2$bs _ _68 [ 0 ] ) {
case "Tuple2" :
return Tuple2$bs _ _68 [ 2 ] ;
}
throw "Non-exhaustive pattern match in case" ; } ( ) ;
return [ "Tuple2" , b _69 , init _ _7 ( s _ _70 ) ( step _66 ) ] ; } ( ) ; } ) ; } ; } ;
function vecSub _12 ( Tuple2$x1y1 _77 ) {
return function ( Tuple2$x2y2 _78 ) {
return function ( ) {
switch ( Tuple2$x1y1 _77 [ 0 ] ) {
case "Tuple2" :
return function ( ) {
switch ( Tuple2$x2y2 _78 [ 0 ] ) {
case "Tuple2" :
return [ "Tuple2" , ( Tuple2$x1y1 _77 [ 1 ] - Tuple2$x2y2 _78 [ 1 ] ) , ( Tuple2$x1y1 _77 [ 2 ] - Tuple2$x2y2 _78 [ 2 ] ) ] ;
}
throw "Non-exhaustive pattern match in case" ; } ( ) ;
}
throw "Non-exhaustive pattern match in case" ; } ( ) ; } ; } ;
function stepDrag _13 ( Tuple2$presspos _83 ) {
return function ( Tuple2$dsform _84 ) {
return function ( ) {
switch ( Tuple2$presspos _83 [ 0 ] ) {
case "Tuple2" :
return function ( ) {
switch ( Tuple2$dsform _84 [ 0 ] ) {
case "Tuple2" :
return function ( ) {
function wrap _89 ( ds _ _90 ) {
return [ "Tuple2" , Tuple2$dsform _84 [ 2 ] , [ "Tuple2" , ds _ _90 , Tuple2$dsform _84 [ 2 ] ] ] ; } ;
return function ( ) {
switch ( Tuple2$dsform _84 [ 1 ] [ 0 ] ) {
case "DragFrom" :
return ( Tuple2$presspos _83 [ 1 ] ? [ "Tuple2" , uncurry ( move ) ( vecSub _12 ( Tuple2$presspos _83 [ 2 ] ) ( Tuple2$dsform _84 [ 1 ] [ 1 ] ) ) ( Tuple2$dsform _84 [ 2 ] ) , [ "Tuple2" , DragFrom _11 ( Tuple2$dsform _84 [ 1 ] [ 1 ] ) , Tuple2$dsform _84 [ 2 ] ] ] : function ( ) {
var form _ _92 = uncurry ( move ) ( vecSub _12 ( Tuple2$presspos _83 [ 2 ] ) ( Tuple2$dsform _84 [ 1 ] [ 1 ] ) ) ( Tuple2$dsform _84 [ 2 ] ) ;
return [ "Tuple2" , form _ _92 , [ "Tuple2" , Listen _9 , form _ _92 ] ] ; } ( ) ) ;
case "Ignore" :
return wrap _89 ( ( Tuple2$presspos _83 [ 1 ] ? Ignore _10 : Listen _9 ) ) ;
case "Listen" :
return wrap _89 ( ( not ( Tuple2$presspos _83 [ 1 ] ) ? Listen _9 : ( isWithin ( Tuple2$presspos _83 [ 2 ] ) ( Tuple2$dsform _84 [ 2 ] ) ? DragFrom _11 ( Tuple2$presspos _83 [ 2 ] ) : Ignore _10 ) ) ) ;
}
throw "Non-exhaustive pattern match in case" ; } ( ) ; } ( ) ;
}
throw "Non-exhaustive pattern match in case" ; } ( ) ;
}
throw "Non-exhaustive pattern match in case" ; } ( ) ; } ; } ;
2012-10-19 07:27:12 +00:00
function draggable _14 ( form _93 ) {
2012-10-19 07:13:28 +00:00
return init _ _7 ( [ "Tuple2" , Listen _9 , form _93 ] ) ( stepDrag _13 ) ; } ;
2012-10-19 07:27:12 +00:00
return { Automaton : Automaton _0 , run : run _1 , step : step _2 , composeAuto : composeAuto _3 , combine : combine _4 , pure : pure _5 , init : init _6 , init _ : init _ _7 , count : count _8 , Listen : Listen _9 , Ignore : Ignore _10 , DragFrom : DragFrom _11 , vecSub : vecSub _12 , stepDrag : stepDrag _13 , draggable : draggable _14 } ; } ( ) ;
2012-10-19 07:13:28 +00:00
Elm . main = function ( ) {
return Elm . Automaton . main ; } ;
} catch ( e ) { Elm . main = function ( ) { var 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>' ) ; document . body . innerHTML = Text . monospace ( msg ) ; throw e ; } ; }