2012-11-23 04:31:55 +00:00
( function ( ) {
try {
var $op = { } ;
for ( this [ 'i' ] in Elm ) { eval ( 'var ' + this [ 'i' ] + '=Elm[this.i];' ) ; }
if ( Elm . Automaton ) throw "Module name collision, 'Automaton' is already defined." ;
2012-10-19 07:13:28 +00:00
Elm . Automaton = function ( ) {
2012-11-23 04:31:55 +00:00
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 ( this [ 'i' ] in Elm . Prelude ) {
if ( hiddenVars [ this [ 'i' ] ] ) continue ;
eval ( 'var ' + this [ 'i' ] + ' = Elm.Prelude[this.i];' ) ; }
2012-10-19 07:13:28 +00:00
function Automaton _0 ( a1 ) {
2012-11-23 04:31:55 +00:00
return [ "Automaton" , a1 ] ; }
var Listen _8 = [ "Listen" ] ;
var Ignore _9 = [ "Ignore" ] ;
function DragFrom _10 ( a1 ) {
return [ "DragFrom" , a1 ] ; }
$op [ '>>>' ] = function ( a1 _24 ) {
return function ( a2 _25 ) {
2012-10-19 07:13:28 +00:00
return function ( ) {
2012-11-23 04:31:55 +00:00
var Automaton$m1 _26 = a1 _24 ;
var m1 _27 = function ( ) {
switch ( Automaton$m1 _26 [ 0 ] ) {
2012-10-19 07:13:28 +00:00
case "Automaton" :
2012-11-23 04:31:55 +00:00
return Automaton$m1 _26 [ 1 ] ;
2012-10-19 07:13:28 +00:00
}
throw "Non-exhaustive pattern match in case" ; } ( ) ;
2012-11-23 04:31:55 +00:00
var Automaton$m2 _28 = a2 _25 ;
var m2 _29 = function ( ) {
switch ( Automaton$m2 _28 [ 0 ] ) {
2012-10-19 07:13:28 +00:00
case "Automaton" :
2012-11-23 04:31:55 +00:00
return Automaton$m2 _28 [ 1 ] ;
2012-10-19 07:13:28 +00:00
}
throw "Non-exhaustive pattern match in case" ; } ( ) ;
2012-11-23 04:31:55 +00:00
return Automaton _0 ( function ( a _32 ) {
2012-10-19 07:13:28 +00:00
return function ( ) {
2012-11-23 04:31:55 +00:00
var Tuple2$bm1 _ _33 = m1 _27 ( a _32 ) ;
var b _34 = function ( ) {
switch ( Tuple2$bm1 _ _33 [ 0 ] ) {
2012-10-19 07:13:28 +00:00
case "Tuple2" :
2012-11-23 04:31:55 +00:00
return Tuple2$bm1 _ _33 [ 1 ] ;
2012-10-19 07:13:28 +00:00
}
throw "Non-exhaustive pattern match in case" ; } ( ) ;
2012-11-23 04:31:55 +00:00
var m1 _ _35 = function ( ) {
switch ( Tuple2$bm1 _ _33 [ 0 ] ) {
2012-10-19 07:13:28 +00:00
case "Tuple2" :
2012-11-23 04:31:55 +00:00
return Tuple2$bm1 _ _33 [ 2 ] ;
2012-10-19 07:13:28 +00:00
}
throw "Non-exhaustive pattern match in case" ; } ( ) ;
return function ( ) {
2012-11-23 04:31:55 +00:00
var Tuple2$cm2 _ _40 = m2 _29 ( b _34 ) ;
var c _41 = function ( ) {
switch ( Tuple2$cm2 _ _40 [ 0 ] ) {
2012-10-19 07:13:28 +00:00
case "Tuple2" :
2012-11-23 04:31:55 +00:00
return Tuple2$cm2 _ _40 [ 1 ] ;
2012-10-19 07:13:28 +00:00
}
throw "Non-exhaustive pattern match in case" ; } ( ) ;
2012-11-23 04:31:55 +00:00
var m2 _ _42 = function ( ) {
switch ( Tuple2$cm2 _ _40 [ 0 ] ) {
2012-10-19 07:13:28 +00:00
case "Tuple2" :
2012-11-23 04:31:55 +00:00
return Tuple2$cm2 _ _40 [ 2 ] ;
2012-10-19 07:13:28 +00:00
}
throw "Non-exhaustive pattern match in case" ; } ( ) ;
2012-11-23 04:31:55 +00:00
return [ "Tuple2" , c _41 , $op [ '>>>' ] ( m1 _ _35 ) ( m2 _ _42 ) ] ; } ( ) ; } ( ) ; } ) ; } ( ) ; } ; } ;
$op [ '<<<' ] = function ( a2 _47 ) {
return function ( a1 _48 ) {
return $op [ '>>>' ] ( a1 _48 ) ( a2 _47 ) ; } ; } ;
$op [ '^>>' ] = function ( f _49 ) {
return function ( a _50 ) {
return $op [ '>>>' ] ( pure _4 ( f _49 ) ) ( a _50 ) ; } ; } ;
$op [ '>>^' ] = function ( a _51 ) {
return function ( f _52 ) {
return $op [ '>>>' ] ( a _51 ) ( pure _4 ( f _52 ) ) ; } ; } ;
$op [ '^<<' ] = function ( f _53 ) {
return function ( a _54 ) {
return $op [ '>>>' ] ( a _54 ) ( pure _4 ( f _53 ) ) ; } ; } ;
$op [ '<<^' ] = function ( a _55 ) {
return function ( f _56 ) {
return $op [ '>>>' ] ( pure _4 ( f _56 ) ) ( a _55 ) ; } ; } ;
var count _7 = init _5 ( 0 ) ( function ( _ _84 ) {
return function ( c _85 ) {
return ( 1 + c _85 ) ; } ; } ) ;
function run _1 ( Automaton$m0 _14 ) {
return function ( input _15 ) {
return function ( ) {
switch ( Automaton$m0 _14 [ 0 ] ) {
case "Automaton" :
2013-01-07 08:46:29 +00:00
return lift ( fst ) ( foldp$ ( function ( a _17 ) {
2012-11-23 04:31:55 +00:00
return function ( Tuple2$bAutomaton$m _18 ) {
return function ( ) {
switch ( Tuple2$bAutomaton$m _18 [ 0 ] ) {
case "Tuple2" :
switch ( Tuple2$bAutomaton$m _18 [ 2 ] [ 0 ] ) {
case "Automaton" :
return Tuple2$bAutomaton$m _18 [ 2 ] [ 1 ] ( a _17 ) ;
} break ;
}
throw "Non-exhaustive pattern match in case" ; } ( ) ; } ; } ) ( Automaton$m0 _14 [ 1 ] ) ( input _15 ) ) ;
}
throw "Non-exhaustive pattern match in case" ; } ( ) ; } ; }
function step _2 ( Automaton$m _21 ) {
return function ( a _22 ) {
return function ( ) {
switch ( Automaton$m _21 [ 0 ] ) {
case "Automaton" :
return Automaton$m _21 [ 1 ] ( a _22 ) ;
}
throw "Non-exhaustive pattern match in case" ; } ( ) ; } ; }
function combine _3 ( autos _57 ) {
return Automaton _0 ( function ( a _58 ) {
2012-10-19 07:13:28 +00:00
return function ( ) {
2012-11-23 04:31:55 +00:00
var Tuple2$bsautos _ _59 = unzip ( map ( function ( Automaton$m _62 ) {
2012-10-19 07:13:28 +00:00
return function ( ) {
2012-11-23 04:31:55 +00:00
switch ( Automaton$m _62 [ 0 ] ) {
2012-10-19 07:13:28 +00:00
case "Automaton" :
2012-11-23 04:31:55 +00:00
return Automaton$m _62 [ 1 ] ( a _58 ) ;
2012-10-19 07:13:28 +00:00
}
2012-11-23 04:31:55 +00:00
throw "Non-exhaustive pattern match in case" ; } ( ) ; } ) ( autos _57 ) ) ;
var bs _60 = function ( ) {
switch ( Tuple2$bsautos _ _59 [ 0 ] ) {
2012-10-19 07:13:28 +00:00
case "Tuple2" :
2012-11-23 04:31:55 +00:00
return Tuple2$bsautos _ _59 [ 1 ] ;
2012-10-19 07:13:28 +00:00
}
throw "Non-exhaustive pattern match in case" ; } ( ) ;
2012-11-23 04:31:55 +00:00
var autos _ _61 = function ( ) {
switch ( Tuple2$bsautos _ _59 [ 0 ] ) {
2012-10-19 07:13:28 +00:00
case "Tuple2" :
2012-11-23 04:31:55 +00:00
return Tuple2$bsautos _ _59 [ 2 ] ;
2012-10-19 07:13:28 +00:00
}
throw "Non-exhaustive pattern match in case" ; } ( ) ;
2012-11-23 04:31:55 +00:00
return [ "Tuple2" , bs _60 , combine _3 ( autos _ _61 ) ] ; } ( ) ; } ) ; }
function pure _4 ( f _68 ) {
return Automaton _0 ( function ( x _69 ) {
return [ "Tuple2" , f _68 ( x _69 ) , pure _4 ( f _68 ) ] ; } ) ; }
function init _5 ( s _70 ) {
return function ( step _71 ) {
return Automaton _0 ( function ( a _72 ) {
2012-10-19 07:13:28 +00:00
return function ( ) {
2012-11-23 04:31:55 +00:00
var s _ _73 = step _71 ( a _72 ) ( s _70 ) ;
return [ "Tuple2" , s _ _73 , init _5 ( s _ _73 ) ( step _71 ) ] ; } ( ) ; } ) ; } ; }
function init _ _6 ( s _74 ) {
return function ( step _75 ) {
return Automaton _0 ( function ( a _76 ) {
2012-10-19 07:13:28 +00:00
return function ( ) {
2012-11-23 04:31:55 +00:00
var Tuple2$bs _ _77 = step _75 ( a _76 ) ( s _74 ) ;
var b _78 = function ( ) {
switch ( Tuple2$bs _ _77 [ 0 ] ) {
2012-10-19 07:13:28 +00:00
case "Tuple2" :
2012-11-23 04:31:55 +00:00
return Tuple2$bs _ _77 [ 1 ] ;
2012-10-19 07:13:28 +00:00
}
throw "Non-exhaustive pattern match in case" ; } ( ) ;
2012-11-23 04:31:55 +00:00
var s _ _79 = function ( ) {
switch ( Tuple2$bs _ _77 [ 0 ] ) {
2012-10-19 07:13:28 +00:00
case "Tuple2" :
2012-11-23 04:31:55 +00:00
return Tuple2$bs _ _77 [ 2 ] ;
2012-10-19 07:13:28 +00:00
}
throw "Non-exhaustive pattern match in case" ; } ( ) ;
2012-11-23 04:31:55 +00:00
return [ "Tuple2" , b _78 , init _ _6 ( s _ _79 ) ( step _75 ) ] ; } ( ) ; } ) ; } ; }
function vecSub _11 ( Tuple2$x1y1 _86 ) {
return function ( Tuple2$x2y2 _87 ) {
2012-10-19 07:13:28 +00:00
return function ( ) {
2012-11-23 04:31:55 +00:00
switch ( Tuple2$x1y1 _86 [ 0 ] ) {
2012-10-19 07:13:28 +00:00
case "Tuple2" :
return function ( ) {
2012-11-23 04:31:55 +00:00
switch ( Tuple2$x2y2 _87 [ 0 ] ) {
2012-10-19 07:13:28 +00:00
case "Tuple2" :
2012-11-23 04:31:55 +00:00
return [ "Tuple2" , ( Tuple2$x1y1 _86 [ 1 ] - Tuple2$x2y2 _87 [ 1 ] ) , ( Tuple2$x1y1 _86 [ 2 ] - Tuple2$x2y2 _87 [ 2 ] ) ] ;
2012-10-19 07:13:28 +00:00
}
throw "Non-exhaustive pattern match in case" ; } ( ) ;
}
2012-11-23 04:31:55 +00:00
throw "Non-exhaustive pattern match in case" ; } ( ) ; } ; }
function stepDrag _12 ( Tuple2$presspos _92 ) {
return function ( Tuple2$dsform _93 ) {
2012-10-19 07:13:28 +00:00
return function ( ) {
2012-11-23 04:31:55 +00:00
switch ( Tuple2$presspos _92 [ 0 ] ) {
2012-10-19 07:13:28 +00:00
case "Tuple2" :
return function ( ) {
2012-11-23 04:31:55 +00:00
switch ( Tuple2$dsform _93 [ 0 ] ) {
2012-10-19 07:13:28 +00:00
case "Tuple2" :
return function ( ) {
2012-11-23 04:31:55 +00:00
function wrap _98 ( ds _ _99 ) {
return [ "Tuple2" , Tuple2$dsform _93 [ 2 ] , [ "Tuple2" , ds _ _99 , Tuple2$dsform _93 [ 2 ] ] ] ; }
2012-10-19 07:13:28 +00:00
return function ( ) {
2012-11-23 04:31:55 +00:00
switch ( Tuple2$dsform _93 [ 1 ] [ 0 ] ) {
2012-10-19 07:13:28 +00:00
case "DragFrom" :
2012-11-23 04:31:55 +00:00
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 ( ) {
var form _ _101 = uncurry ( move ) ( vecSub _11 ( Tuple2$presspos _92 [ 2 ] ) ( Tuple2$dsform _93 [ 1 ] [ 1 ] ) ) ( Tuple2$dsform _93 [ 2 ] ) ;
return [ "Tuple2" , form _ _101 , [ "Tuple2" , Listen _8 , form _ _101 ] ] ; } ( ) ) ;
2012-10-19 07:13:28 +00:00
case "Ignore" :
2012-11-23 04:31:55 +00:00
return wrap _98 ( ( Tuple2$presspos _92 [ 1 ] ? Ignore _9 : Listen _8 ) ) ;
2012-10-19 07:13:28 +00:00
case "Listen" :
2012-11-23 04:31:55 +00:00
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 ) ) ) ;
2012-10-19 07:13:28 +00:00
}
throw "Non-exhaustive pattern match in case" ; } ( ) ; } ( ) ;
}
throw "Non-exhaustive pattern match in case" ; } ( ) ;
}
2012-11-23 04:31:55 +00:00
throw "Non-exhaustive pattern match in case" ; } ( ) ; } ; }
function draggable _13 ( form _102 ) {
return init _ _6 ( [ "Tuple2" , Listen _8 , form _102 ] ) ( stepDrag _12 ) ; }
return { $op : { '>>>' : $op [ '>>>' ] , '<<<' : $op [ '<<<' ] , '^>>' : $op [ '^>>' ] , '>>^' : $op [ '>>^' ] , '^<<' : $op [ '^<<' ] , '<<^' : $op [ '<<^' ] } ,
run : run _1 ,
step : step _2 ,
combine : combine _3 ,
pure : pure _4 ,
init : init _5 ,
2013-01-06 00:27:36 +00:00
init$ : init _ _6 ,
2012-11-23 04:31:55 +00:00
count : count _7 ,
draggable : draggable _13 } ; } ( ) ;
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 = Elm . Text . monospace ( msg ) ; throw e ; } ; } } ( ) ) ;