randrun emits a shuffled run of the integers below n, one distinct value per step
randrun n generates a pattern of random integers less than n. Unlike irand, which draws independently (values may repeat), randrun behaves like a randomized run: it walks through the integers 0..n-1 in a shuffled order, so within a cycle each value appears. It cannot be dropped into a pattern the same way as run; because it yields Pattern Int, mapping it onto notes requires Haskell’s fromIntegral to convert to the numeric type n expects. Feeding the result through scale turns the raw random run into something musical rather than atonal.
Examples
d1 $ s “superpiano!16” # n (fmap fromIntegral $ randrun 13) d1 $ s “superpiano!16” # n (scale “hexSus” (fmap fromIntegral $ randrun 13))
Assessment
Explain the difference in output between irand 8 and randrun 8 over one cycle, and state why randrun needs fromIntegral before it can drive # n.