optimizing a rollercoaster queue
So I found a few improvements which solve my problem. First, I used a vector to represent the queue, and a rolling index to store the head of the queue:

type Queue = V.Vector Int
data RollingQ = RollingQ Queue Int

currentVal :: RollingQ -&gt; Int
currentVal (RollingQ v i) = v V.! i

nextVal :: RollingQ -&gt; RollingQ
nextVal (RollingQ v i)
    | i == V.length v = RollingQ v 0
    | otherwise = RollingQ v (i + 1)


This led me to realize that there might be a cycle in the computation: if the number of rides is bigger than the number of groups in the queue, the state of the queue loops. I used a Map to remember information about the computation to detect the loop and compute a shortcut to get the result almost immediately.