Kanban Board Reducer
Hard · Discriminated Unions
Write a pure reducer(board, action) for a kanban board (Action is a discriminated union, see the starter). On success return { board: newBoard, error: null } without changing the old board. On failure return the SAME board and an error:
- addColumn: "column exists".
- addCard: "no column", "card exists" (anywhere on the board), "column full" (cards.length >= limit), checked in this order.
- moveCard: "no card", "no column", then "column full" if the target is another column that is full. Remove the card, then insert it at index clamped to 0..length of the target list.
- removeColumn: "no column", "column not empty".
- setLimit: "no column", "limit too low" (below the number of cards).
- Any other type: call assertNever (it throws).
The driver runBoard(actions) is already written.
Next: Implement allSettled