This is function, that works correctly, but it seems to be too ugly.
panel argument is never used for anything but pushing into refreshGamePanel,
and it seems to be too much case statements. How can I cleanup this?
runGameLoop :: Game -> Panel -> Curses GameResult
runGameLoop game panel
= if victory game then return Victory else
refreshGamePanel game panel >> render >> getPanelWindow panel >>=
flip getEvent (Just 1)
>>=
\ event' ->
case event' of
Nothing -> runGameLoop game panel
Just event -> case event of
EventSpecialKey (KeyFunction 2) -> return Restart
EventSpecialKey (KeyFunction 10) -> return Quit
EventSpecialKey key' -> case keyToDirection key' of
Nothing -> runGameLoop game panel
Just dir -> runGameLoop (makeMove game dir) panel
_ -> runGameLoop game panel
donotation? Further, look for more idiomatic ways to deal withMaybe(how aboutfromMaybe?). \$\endgroup\$