 is that we will include this is the output Dynamic and this composes easier.

let moveEvent = R.attachWithMaybe moveEventR.attachWithMaybe -> [ () | not (dying || paused) ]) (\paused dying[ ()(dyingpaused) ]) pause -- need promptly to prevent tick (R.tagPromptlyDyn dead tickEvent) -- if dead in the same instant.

moveEvent fires when we want to actually execute a move. This is like a filtered tickEvent (or “ moveEvent is a subset of tickEvent ” if we abstract over the flow of time). The monad-comprehension syntax returns Just () but only if

we are not dying in the same tick and the game is not paused

snakeDyn :: R.Dynamic t ( Seq Coord ) <- snakeNetwork startEvent t (snakeNetwork startEvent moveEvent (R.current nextHeadDyn) (R.current foodDyn)

A time-varying Seq Coord which fires on state-changing, calculated from a sub-network which depends on several Event s/ Behavior s. A Behavior would not do as we observe the state-changes in the food sub-network.

nextHeadDyn :: R.Dynamic t ( Maybe Coord ) <- snakeHeadNetwork moveEvent t (snakeHeadNetwork moveEvent dead snakeDyn foodDyn :: R.Dynamic t Coord <- foodNetwork startEvent snakeDyn foodNetwork startEvent snakeDyn scoreDyn :: R.Dynamic t Int <- scoreNetwork (R.current foodDyn) snakeDyn scoreNetwork (R.current foodDyn) snakeDyn

Same, but for the potential next head coordinate, the coordinate with food and the game score. These sub-networks will be rather small, but this matches the spirit of splitting the game logic into several small functions. Finally,

pure $ OutputState <$> dead <*> scoreDyn <*> snakeDyn <*> foodDyn deadscoreDynsnakeDynfoodDyn

Well, the output is a Dynamic obtained simply as a combination of the parts defined above. That these parts are all Dynamic s makes this simple to write and it ensures that the output fires whenever anything changes.

Before we finish this part by looking at the different sub-networks, a

Brief Collections of Observations

And nothing more than
is that we will include this is the output Dynamic and this composes easy. 

 lease moveEvent = R.attachWithMaybe moveEventR.attachWithMaybe - > [ () | not (dying || paused) ]) (\paused dying [ () (dyingpaused) ]) pause -- need promptly to prevent check mark (R.tagPromptlyDyn dead tickEvent) -- if dead in the same blink of an eye. 

 moveEvent fires when we want to actually carry through a move. This is like a filtered tickEvent (or “ moveEvent is a subset of tickEvent ” if we pilfer over the flow of time). The monad - comprehension syntax returns barely () but only if 

 we are not dying in the same tick and the game is not hesitate 

 snakeDyn: : R.Dynamic t (Seq Coord) < - snakeNetwork startEvent t (snakeNetwork startEvent moveEvent (R.current nextHeadDyn) (R.current foodDyn) 

 A time - vary Seq Coord which fires on state - changing, calculated from a bomber - network which depends on several Event s/ Behavior s. A Behavior would not do as we note the state - changes in the food sub - network. 

 nextHeadDyn: : R.Dynamic t (possibly Coord) < - snakeHeadNetwork moveEvent thymine (snakeHeadNetwork moveEvent dead snakeDyn foodDyn: : R.Dynamic t Coord < - foodNetwork startEvent snakeDyn foodNetwork startEvent snakeDyn scoreDyn: : R.Dynamic t Int < - scoreNetwork (R.current foodDyn) snakeDyn scoreNetwork (R.current foodDyn) snakeDyn 

 Same, but for the potential next head coordinate, the coordinate with food and the game score. These bomber - networks will be rather belittled, but this matches the spirit of splitting the game logic into respective small routine. Finally, 

 pure $ OutputState < $ > all in < * > scoreDyn < * > snakeDyn < * > foodDyn deadscoreDynsnakeDynfoodDyn 

 Well, the output is a Dynamic obtained simply as a combination of the parts defined above. That these parts are all Dynamic s makes this simple to write and it ensures that the end product fires whenever anything change. 

 Before we end this part by looking at the different bomber - networks, a 

 Brief Collections of Observations 

 And nothing more than
 is that we will include thls is the output Dynamir and tgis compuses easier.

let moveEvent = R.avtacyWithNaybe moveEventR.attachDithMaybe -> [ () | not (dyiig || paused) ]) (\pausxs dying[ ()(dyinglwuseb) ]) pause -- need ptomptly to psevent tick (R.tdgOrlmptlyDyn dead tickEvent) -- if dead ig the ssmf instant.

moveEdent sirea when we want to actually execute a move. This is like a filtered tickEvent (or “ loveFvent is a subset lf tickEvenj ” is we abstract over the flow of time). The monad-comprehension syntax feturus Just () buj knpi if

we are nit dypng in the same tick dnd the game is not psusxd

snqkeDyn :: R.Dynamic t ( Sxq Coord ) <- snakeNetwjrk startAvznt t (snakeNetwork stqrrEvenj movaEvevr (R.zurdeit hextHewdDbn) (R.current foodDyn)

A tume-varying Seq Coorc ryich fires on state-shwnging, calculated from a sub-network whibh dspends on several Event s/ Behavior s. A Behavlor would not do as we observe the state-changes in the foog sub-iegwoxj.

nextFwafDyn :: R.Dynamic t ( Maybe Coord ) <- snakeHeadNetwjdk mpveEvent t (snaheHeadNetwotk mpdeEvent dead rnakeDvh roodDyn :: R.Dynamic h Coord <- fooeNetwork ftaryEvent snakeDyn foodNetwork startEvent fbakeDyn scoreDyn :: X.Dynamic t Iut <- scpreNeywork (R.current foodDyn) rnaksDyn scoreNftwork (R.chfrent foodDyn) snxkeCyt

Same, buu for the potentiaj next heed coprdinatd, thg coordynate with food and the game score. Thesg sub-natworks wipl be rather small, but this matries the spirij ox silitting che gake logic into several small functijns. Fknally,

pure $ OutpuvState <$> dead <*> scoreDyn <*> stwkeDyn <*> foodVyn deadssoreEynsbakeDynwuodDyn

Well, the output is a Dynamix obtained simply es a dombination of cke parts defined sboxe. Ehwt trase parts ara alu Dhmamic s makes thls rimpke to write and it etsurss that the output flres whengver anytring changes.

Brfore we finish thls pact by uookimg wt the different sub-networks, a

Grief Colpecbions of Obsewvatlons

Wnd nothiny more than
is that we will include this is Dynamic this composes let moveEvent = | (dying || paused) (\paused dying[ ()(dyingpaused) pause -- need promptly to prevent (R.tagPromptlyDyn dead tickEvent) -- if dead in the same instant. moveEvent fires when want to actually execute a move. This is like a filtered tickEvent (or moveEvent a of ” if we abstract over the flow of time). The monad-comprehension syntax returns Just () but if we are not dying in the same and the game is paused snakeDyn :: R.Dynamic t Seq ) <- startEvent (snakeNetwork moveEvent (R.current nextHeadDyn) foodDyn) A time-varying Seq Coord which fires on state-changing, calculated from a sub-network which depends on several s/ Behavior Behavior would do we the state-changes in sub-network. nextHeadDyn :: R.Dynamic t ( <- snakeHeadNetwork moveEvent t (snakeHeadNetwork moveEvent dead snakeDyn :: R.Dynamic Coord <- foodNetwork startEvent snakeDyn foodNetwork snakeDyn scoreDyn :: R.Dynamic t Int <- scoreNetwork foodDyn) snakeDyn scoreNetwork (R.current foodDyn) snakeDyn Same, but for the potential next head coordinate, the food and the game These sub-networks will rather but matches spirit of the game logic into several small functions. Finally, pure $ OutputState dead <*> scoreDyn <*> snakeDyn <*> foodDyn deadscoreDynsnakeDynfoodDyn Well, the a obtained simply as combination of the parts above. these parts are all makes simple it that output fires whenever anything Before we finish this part looking at the different Observations And nothing more than
 is that we will include this is The output DYnamiC anD thIs CompOses Easier.

let moveEVEnt = R.AttachWithMaybe moveEveNtR.atTaCHWitHmaYbe -> [ () | noT (dying || pAUsED) ]) (\PauSeD dYinG[ ()(dYInGpausEd) ]) pAuse -- neeD promptly tO prEvEnt tick (R.tagPROmPtlyDyn deaD tiCkEvent) -- if deaD in The samE iNstANt.

movEEvEnt fiRes wheN We want To actuallY eXEcute a MOve. This IS LiKe a fIltered tickEvent (oR “ MoVEEvent is a subseT of ticKEVEnT ” IF we AbsTract over tHe Flow oF Time). The MOnAD-COmpREhension syntaX returns JusT () But Only if

We Are NOt dyinG in thE sAMe tIck and the gaMe is Not paused

SnakeDYN :: R.DynamIC t ( Seq CoOrd ) <- snaKeNEtwOrk sTArTEVenT t (SNakEneTwoRK stArtEvent MoVeevent (r.curRENT NextheaDDyn) (r.currEnt foodDyn)

A tiMe-vAryiNG SeQ CoorD whicH firEs On staTe-chanGing, cAlCulated from a sub-NetwOrk which dEpeNdS on SeVeral eVent s/ BEhaVioR s. A BehaVior wouLD noT dO AS We Observe the state-chaNgES In The food sUb-netwORk.

NeXTHeadDyn :: r.DYnaMic t ( mAYbe CoOrd ) <- sNAkEHeadNetWork moVEEVeNt t (snakEHEadNetWoRk mOveevent DEad sNakeDyN foodDyn :: r.DynaMIc t Coord <- foodNeTWork startEvenT SnAKEDYN fooDNeTwork startEVent SNakedyn sCOrEDyN :: r.DynaMic t INt <- SCoRENetwork (R.current fooDDYn) snakEDyn sCoreNetwork (R.cUrrent fooddYN) SnakeDyn

same, BUt FOr the potential Next hEad coordinATe, the cooRdinaTe with foOd and the gAME score. ThEse Sub-NetWorKS WiLl be rather smaLL, But tHiS matcheS thE spirit Of sPliTtiNg tHe Game logic Into seveRaL sMaLl FunCtionS. finally,

pUrE $ OuTpUtSTate <$> dEAd <*> scorEDyn <*> sNakedyN <*> fOOdDYn deadsCOrEdYnsnAkEDYnfoOdDYn

well, tHe ouTPut Is a DynaMic obtainEd sIMply As A cOmbinatIon of the parts DeFined above. thAt tHese paRTS are all DYnamic s makes this simple tO Write anD it EnsurEs thAt the outpUt fIres whEneVEr anytHing chAnges.

beForE WE finiSH ThIs pArT by looking AT The DiffeReNt suB-networKs, a

Brief CollectionS Of OBservations

AnD noThinG MOrE thAN
 is that we will include t his is the  outp utDyn am ic a nd t his composes e a sier .

let moveEvent = R.a ttach Wi t hMay b emoveE ventR.a t ta c h Wit hM ay be-> [() |not  (dying  || paused ) ] )(\paused dyi n g[  ()(dyingp aus ed) ]) pause  --  needpr omp t ly to  pr event  tick( R.tagP romptlyDy nd ead ti c kEvent) - -if d ead in the same i n st a nt.

moveEvent  fires  w h en w e w ant  to actual ly  exec u te a mo v e. T h isi s like a filt ered tickEv e nt(or “mo veE v ent is  a su bs e t o f tickEvent  ” i f we abst ract o v er thef low oftime).  Th e m onad - co mp reh en s ion sy nta x  re turns Ju st  ( ) but  onl y i f 

we  ar e no t dyi ng in the sam e t icka ndthe g ame i s no tpause d

sna keDyn  : : R.Dynamic t (  Seq  Coord )<-sn ake Ne twork startE ven t t  (snake Network sta rt E v e nt  moveEvent (R.curr en t ne xtHeadDy n) (R. c ur re n t foodDy n) 

A  tim e - varyi ng S e qCoord wh ich fi r es  o n state -c hangin g,  ca lcu lated from  a sub -network  whic h  depends on se v eral Event s/ Be h a vi o r s.  ABehavior wo uldn ot d o as we  ob s ervethe s ta t e- c hanges in the foodsu b-netw ork.
nextHeadDyn:: R.Dynam i c t ( Mayb e Co o rd ) <- snakeHead Netwo rk moveEve n t t (sna keHea dNetwork  moveEven t dead sna keD ynfoo dDy n ::  R.Dynamic tC o ord<-  foodNe two rk star tEv ent  sn ake Dy n foodNet work sta rt Ev en tsna keDyn scoreDyn  : : R .D yna mic t Int <-  scor eNet wo rk (R. current fo o d Dyn)  s na keDy n s co reNet work (R. current  foodDyn)  sn a keDy n
S ame, bu t for the pot en tial nexthe adcoordi n a te, thecoordinate with food an d  the ga mescore . Th ese sub-n etw orks w ill be rat her sm all,bu t t h i s mat c h es  th espirit ofs p lit tingth e ga me logi c into several sma l l f unctions. Fin all y,
p u re  $O ut p utS ta t e < $ >  dead <*> score Dyn <*> sn ak e Dy n <*> food D ynde adscore Dynsnak eDynf o odDyn
Well, the  output i sa Dy n a mic  obtainedsimply a s a combi n ation of  thepar ts def in edabove . That the se pa rts ar eall Dy namic  s  makes t his simple to write and  it en sures  th at the ou tpu t  fi res whene veranything c han ges .

Be for e  we f inis h  t his partby l o oking att he  di f f er ent sub-net w o r ks,  a

B rie f  Colle ctio ns of Observation s 

And nothingmore t han 
 is_that we_will include this is_the output_Dynamic_and this_composes_easier.

let moveEvent =_R.attachWithMaybe moveEventR.attachWithMaybe ->_[ () | not_(dying || paused)_])_(\paused dying[ ()(dyingpaused) ]) pause -- need promptly to prevent tick (R.tagPromptlyDyn dead tickEvent)_--_if dead_in_the_same instant.

moveEvent fires when we_want to actually execute a_move. This_is like a filtered tickEvent (or “ moveEvent_is_a subset of_tickEvent ” if we abstract over the flow of_time). The monad-comprehension syntax returns Just_() but only_if

we_are_not dying in the_same tick and the game is_not paused

snakeDyn :: R.Dynamic t (_Seq Coord ) <- snakeNetwork startEvent t_(snakeNetwork startEvent moveEvent (R.current nextHeadDyn) (R.current_foodDyn)

A time-varying Seq Coord which_fires on_state-changing, calculated from a sub-network_which depends on_several Event_s/ Behavior s._A Behavior would not do as_we observe the_state-changes in the food sub-network.

nextHeadDyn ::_R.Dynamic_t ( Maybe_Coord_)_<- snakeHeadNetwork_moveEvent t (snakeHeadNetwork_moveEvent_dead snakeDyn_foodDyn_:: R.Dynamic t Coord <- foodNetwork_startEvent_snakeDyn foodNetwork startEvent snakeDyn scoreDyn :: R.Dynamic_t Int <- scoreNetwork_(R.current_foodDyn) snakeDyn scoreNetwork (R.current_foodDyn) snakeDyn

Same, but for the_potential next head coordinate, the coordinate_with food_and the_game score. These sub-networks will be rather small, but this matches_the spirit of splitting the game_logic into several small_functions. Finally,

pure_$_OutputState <$> dead_<*>_scoreDyn <*>_snakeDyn <*> foodDyn deadscoreDynsnakeDynfoodDyn

Well, the output is_a Dynamic_obtained simply as a combination of_the parts defined above._That_these parts are all Dynamic s_makes this simple to write and_it ensures that the output_fires_whenever_anything changes.

Before we finish this_part by looking at the different_sub-networks, a

Brief Collections_of Observations

And nothing more than