I am making Pacman in Haskell Gloss. Now I am trying to Exit the game, once all the chips on the gameboard have been eaten by pacman. I have the function to check if that is the case, but I can't find a way to exit the game after that.
This is because I don't have a function that returns an IO a (because exitWith outputs that).
Here is the code of my Main.hs:
window :: Display
window = FullScreen
background :: Color
background = black
fps :: Int
fps = 5
main :: IO ()
main = playIO (InWindow "Pacman" (600, 600) (0, 0)) -- Or FullScreen
background -- Background color
fps -- Frames per second
initialState -- Initial state
view -- View function
input -- Event function
step -- Step function from controller
The playIO function has the following type signature:
playIO :: Display ->
Color ->
Int ->
world ->
(world -> IO Picture) ->
(Event -> world -> IO world) ->
(Float -> world -> IO world) ->
IO ()
I might be overlooking something, but I would like to exit the loop of the playIO function once there is a winner. The following function might be of help:
exitWith :: ExitCode -> IO a
Any advice is greatly appreciated, I am still new to Haskell/Gloss.