I'm trying to implement a main loop of sorts in Haskell, in C I would write it like this:
EntityInteraction *frame(Entity *eList, EntityInteraction *iList) {
parseInteractions(eList, iList);
return simulateEntities(eList);
}
int main() {
Entity eList[] = {...}
EntityInteraction *iList = NULL;
while(true) {
iList = frame(eList, iList);
}
}
So I attempted to replicate this in haskell by making frame a recursive function:
frame :: [Entity] -> [EntityInteraction] -> IO ()
frame eList iList = do
frame (parseInteractions iList eList) (simulateEntities eList)
main :: IO ()
main = do
let entList = [...]
frame entList []
But this just results in a stack overflow as expected, so my question is what is the propper way to do a main loop in haskell that uses mutable state?
(I've been programming in C as a hobby for 4 years and I'm just starting to learn haskell)