rands :: Fractional a => Int -> Pattern [a]
rands k = Pattern $ \(State a@(Arc s e) _)
-> [Event (Context []) Nothing a (map realToFrac $ (timeToRands ((e + s)/2) k :: [Double]))]
randrun' :: Int -> Pattern Int
randrun' n = segment 1 (rands n) >>= \ rs ->
let go [] [] = []
go (r:rs) xs =
let i = floor (r * fromIntegral (length xs))
(pre, p:ost) = splitAt i xs
in p : go rs (pre <> ost)
in fastcat $ map pure $ go rs [0 .. n-1]
see discussion at https://club.tidalcycles.org/t/randomness-at-the-beginnings-of-time-function-randrun/5060/2
possible alternate implementation