mardi 4 octobre 2016

How to sample random values in an ST monad?

If I have a random value generator in the RVar monad

ranfu :: RVal Bool

and a higher-order function that does some kind of traversal in (e.g.) the ST monad

stTrav :: PrimMonad m => (Int -> m b) -> m [b]

then how could I use ranfu in the loop of this traversal? Do I need to channel the state of the RVal through an STRef, or is there a better way?




Aucun commentaire:

Enregistrer un commentaire