delayEn :: Coroutine (Int, Event e) (Event e)
delayEn = Coroutine $ step 0 IntMap.empty where
    step !cur !buffer (delay, ev) = (ev', Just $ Coroutine $ step (cur+1) buffer') where
        ev' = IntMap.findWithDefault [] cur buffer'
        buffer'
            | null ev   = buffer
            | otherwise = IntMap.insertWith (++) (cur+delay) ev buffer
delayEn :: Coroutine (Int, Event e) (Event e)
delayEn = Coroutine $ step 0 IntMap.empty where
    step !cur !buffer (delay, ev) = (ev', Just $ Coroutine $ step (cur+1) buffer') where
        ev' = IntMap.findWithDefault [] cur buffer'
        buffer'
            | null ev   = buffer
            | otherwise = IntMap.insertWith (++) (cur+delay) ev buffer
delayEn = Coroutine $ step 0 IntMap.empty where
    step !cur !buffer (delay, ev) = (ev', Just $ Coroutine $ step (cur+1) buffer') where
        ev' = IntMap.findWithDefault [] cur buffer'
        buffer'
            | null ev   = buffer
            | otherwise = IntMap.insertWith (++) (cur+delay) ev buffer