2013-01-29 20:42:56 +00:00
( function ( ) {
try {
var $op = { } ;
for ( this [ 'i' ] in Elm ) { eval ( 'var ' + this [ 'i' ] + '=Elm[this.i];' ) ; }
if ( Elm . Automaton ) throw new Error ( "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 ( this [ 'i' ] in Elm . Prelude ) {
if ( hiddenVars [ this [ 'i' ] ] ) continue ;
eval ( 'var ' + this [ 'i' ] + ' = Elm.Prelude[this.i];' ) ; }
function Automaton _0 ( a1 ) {
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 ) {
return function ( ) {
var Automaton$m1 _26 = a1 _24 ;
var m1 _27 = function ( ) {
switch ( Automaton$m1 _26 [ 0 ] ) {
case "Automaton" :
return Automaton$m1 _26 [ 1 ] ;
}
throw new Error ( "Non-exhaustive pattern match in case" ) ; } ( ) ;
var Automaton$m2 _28 = a2 _25 ;
var m2 _29 = function ( ) {
switch ( Automaton$m2 _28 [ 0 ] ) {
case "Automaton" :
return Automaton$m2 _28 [ 1 ] ;
}
throw new Error ( "Non-exhaustive pattern match in case" ) ; } ( ) ;
return Automaton _0 ( function ( a _32 ) {
return function ( ) {
var Tuple2$bm1 _ _33 = m1 _27 ( a _32 ) ;
var b _34 = function ( ) {
switch ( Tuple2$bm1 _ _33 [ 0 ] ) {
case "Tuple2" :
return Tuple2$bm1 _ _33 [ 1 ] ;
}
throw new Error ( "Non-exhaustive pattern match in case" ) ; } ( ) ;
var m1 _ _35 = function ( ) {
switch ( Tuple2$bm1 _ _33 [ 0 ] ) {
case "Tuple2" :
return Tuple2$bm1 _ _33 [ 2 ] ;
}
throw new Error ( "Non-exhaustive pattern match in case" ) ; } ( ) ;
return function ( ) {
var Tuple2$cm2 _ _40 = m2 _29 ( b _34 ) ;
var c _41 = function ( ) {
switch ( Tuple2$cm2 _ _40 [ 0 ] ) {
case "Tuple2" :
return Tuple2$cm2 _ _40 [ 1 ] ;
}
throw new Error ( "Non-exhaustive pattern match in case" ) ; } ( ) ;
var m2 _ _42 = function ( ) {
switch ( Tuple2$cm2 _ _40 [ 0 ] ) {
case "Tuple2" :
return Tuple2$cm2 _ _40 [ 2 ] ;
}
throw new Error ( "Non-exhaustive pattern match in case" ) ; } ( ) ;
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" :
return lift ( fst ) ( foldp$ ( function ( a _17 ) {
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 new Error ( "Non-exhaustive pattern match in case" ) ; } ( ) ; } ; } ) ( Automaton$m0 _14 [ 1 ] ) ( input _15 ) ) ;
}
throw new Error ( "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 new Error ( "Non-exhaustive pattern match in case" ) ; } ( ) ; } ; }
function combine _3 ( autos _57 ) {
return Automaton _0 ( function ( a _58 ) {
return function ( ) {
var Tuple2$bsautos _ _59 = unzip ( map ( function ( Automaton$m _62 ) {
return function ( ) {
switch ( Automaton$m _62 [ 0 ] ) {
case "Automaton" :
return Automaton$m _62 [ 1 ] ( a _58 ) ;
}
throw new Error ( "Non-exhaustive pattern match in case" ) ; } ( ) ; } ) ( autos _57 ) ) ;
var bs _60 = function ( ) {
switch ( Tuple2$bsautos _ _59 [ 0 ] ) {
case "Tuple2" :
return Tuple2$bsautos _ _59 [ 1 ] ;
}
throw new Error ( "Non-exhaustive pattern match in case" ) ; } ( ) ;
var autos _ _61 = function ( ) {
switch ( Tuple2$bsautos _ _59 [ 0 ] ) {
case "Tuple2" :
return Tuple2$bsautos _ _59 [ 2 ] ;
}
throw new Error ( "Non-exhaustive pattern match in case" ) ; } ( ) ;
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 ) {
return function ( ) {
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 ) {
return function ( ) {
var Tuple2$bs _ _77 = step _75 ( a _76 ) ( s _74 ) ;
var b _78 = function ( ) {
switch ( Tuple2$bs _ _77 [ 0 ] ) {
case "Tuple2" :
return Tuple2$bs _ _77 [ 1 ] ;
}
throw new Error ( "Non-exhaustive pattern match in case" ) ; } ( ) ;
var s _ _79 = function ( ) {
switch ( Tuple2$bs _ _77 [ 0 ] ) {
case "Tuple2" :
return Tuple2$bs _ _77 [ 2 ] ;
}
throw new Error ( "Non-exhaustive pattern match in case" ) ; } ( ) ;
return [ "Tuple2" , b _78 , init _ _6 ( s _ _79 ) ( step _75 ) ] ; } ( ) ; } ) ; } ; }
function vecSub _11 ( Tuple2$x1y1 _86 ) {
return function ( Tuple2$x2y2 _87 ) {
return function ( ) {
switch ( Tuple2$x1y1 _86 [ 0 ] ) {
case "Tuple2" :
return function ( ) {
switch ( Tuple2$x2y2 _87 [ 0 ] ) {
case "Tuple2" :
return [ "Tuple2" , ( Tuple2$x1y1 _86 [ 1 ] - Tuple2$x2y2 _87 [ 1 ] ) , ( Tuple2$x1y1 _86 [ 2 ] - Tuple2$x2y2 _87 [ 2 ] ) ] ;
}
throw new Error ( "Non-exhaustive pattern match in case" ) ; } ( ) ;
}
throw new Error ( "Non-exhaustive pattern match in case" ) ; } ( ) ; } ; }
function stepDrag _12 ( Tuple2$presspos _92 ) {
return function ( Tuple2$dsform _93 ) {
return function ( ) {
switch ( Tuple2$presspos _92 [ 0 ] ) {
case "Tuple2" :
return function ( ) {
switch ( Tuple2$dsform _93 [ 0 ] ) {
case "Tuple2" :
return function ( ) {
function wrap _98 ( ds _ _99 ) {
return [ "Tuple2" , Tuple2$dsform _93 [ 2 ] , [ "Tuple2" , ds _ _99 , Tuple2$dsform _93 [ 2 ] ] ] ; }
return function ( ) {
switch ( Tuple2$dsform _93 [ 1 ] [ 0 ] ) {
case "DragFrom" :
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 ] ] ; } ( ) ) ;
case "Ignore" :
return wrap _98 ( ( Tuple2$presspos _92 [ 1 ] ? Ignore _9 : Listen _8 ) ) ;
case "Listen" :
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 ) ) ) ;
}
throw new Error ( "Non-exhaustive pattern match in case" ) ; } ( ) ; } ( ) ;
}
throw new Error ( "Non-exhaustive pattern match in case" ) ; } ( ) ;
}
throw new Error ( "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 ,
init$ : init _ _6 ,
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>' ) ;
2012-11-23 04:31:55 +00:00
document . body . innerHTML = Elm . Text . monospace ( msg ) ; throw e ; } ; } } ( ) ) ;