Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dobkeratops/f53ac3253ce7b3629e3c95a055c01f9e to your computer and use it in GitHub Desktop.
Save dobkeratops/f53ac3253ce7b3629e3c95a055c01f9e to your computer and use it in GitHub Desktop.
callUpdateWith::UIEvent ->IO ()
callUpdateWith ev=do
mw <-readIORef gWorld
mu <-readIORef gUpdate
ma <-readIORef gAssets
-- is there a cleaner way to do this part:-
-- I think of 'if let' in Rust (if let Some(a),Some(w),Some(u)) ...
-- I also wonder if there's a way to 'pipe' the output of 'callUf u a ev w' into
-- the assignments and 'putStrLn
case (ma,mw,mu) of
(Just a,Just w,Just u)->
let (nw,nu,dbstr)= (callUf u a ev w) in
(gWorld$=Just nw) >> (gUpdate$=Just nu) >> (putStrLn dbstr)
_ -> return ()
{- was..
(nw, nu,dbstr)<-return (
case (ma,mw,mu) of
(Just a,Just w,Just uf)->
let (a,b,dbstr)=callUf uf a ev w in (Just a, Just b, dbstr)
_->(Nothing,Nothing,"no world set")
)
gWorld$=nw
gUpdate$=nu
putStrLn dbstr
-}
return ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment