Solution (source code)

= Solution

The test consumes a state and returns `Bool`; the output function maps a state to an element; and the transition preserves the state type. Hence the most general <polymorphic> <type signature> is

``
unfold :: (s -> Bool) -> (s -> a) -> (s -> s) -> s -> [a]
``

Equivalently, $\boxed{(\sigma\to\mathrm{Bool})\to(\sigma\to\alpha)\to(\sigma\to\sigma)\to\sigma\to[\alpha]}$. The state and emitted element can have unrelated types. A <list unfold> produces the next element from the current state, then advances to a new state.