# Haskell Seq Queues This note covers `44-haskell-seq-queues/`, which uses `Data.Sequence` as a queue for retry work. --- ## 1. Why `Seq` Instead of a Plain List Lists are excellent for recursive processing, but queues want efficient work at both ends: - append new retries to the back, and - take the next retry from the front. `Data.Sequence` provides those operations directly, so the example can talk about queue behavior without building a custom data structure first. --- ## 2. What the Example Demonstrates The queue starts with four retries, then appends one more with `enqueueRetry`. After that, `takeBatch` removes the next `n` items in FIFO order and returns: - the batch to execute now, and - the remaining queue for later. That keeps the example focused on the queue contract, not on concurrency or backoff policy. --- ## 3. Why the Test Uses Rendered Queue State The test checks: - `api#2, worker#1` as the next batch, and - `billing#3, search#1, auth#1` as the remaining queue. That is enough to prove both important properties: - newly enqueued work goes to the back, and - batch selection keeps the original front-to-back order. --- ## 4. Commands to Try ```bash cd 44-haskell-seq-queues nix develop cabal run cabal run -- 3 cabal test nix build ./result/bin/mini-seq-queues 3 nix run . -- 3 nix flake check ```