Random variables. An RVar is a sampleable random variable. Because
probability distributions form a monad, they are quite easy to work with
in the standard Haskell monadic styles. For examples, see the source for
any of the Distribution instances - they all are defined in terms of
RVars.

A random variable with access to operations in an underlying monad. Useful
examples include any form of state for implementing random processes with hysteresis,
or writer monads for implementing tracing of complicated algorithms.

For example, a simple random walk can be implemented as an RVarTIO value:

Invocation is straightforward (although a bit noisy) if you're used
to MTL, but there is a gotcha lurking here: sample and runRVarT
inherit the extreme generality of lift, so there will almost always
need to be an explicit type signature lurking somewhere in any client
code making use of RVarT with MTL types. In this example, the
inferred type of start would be too general to be practical, so the
signature for rwalk explicitly fixes it to Double. Alternatively,
in this case sample could be replaced with
\x -> runRVarTWith MTL.lift x StdRandom.

The Lift context allows random variables to be defined using a minimal
underlying functor (Identity is sufficient for "conventional" random
variables) and then sampled in any monad into which the underlying functor
can be embedded (which, for Identity, is all monads).

The lifting is very important - without it, every RVar would have
to either be given access to the full capability of the monad in which it
will eventually be sampled (which, incidentally, would also have to be
monomorphic so you couldn't sample one RVar in more than one monad)
or functions manipulating RVars would have to use higher-ranked
types to enforce the same kind of isolation and polymorphism.

For non-standard liftings or those where you would rather not introduce a
Lift instance, see runRVarTWith.