types: reimplement rng, rep, rep_i (log-depth); flip (no tail recursion)