A key aspect of understanding complex probabilistic phenomena is determining the causal effect that one random quantity has on another, i.e., determining the extent to which setting the value of one random quantity causes the value of another to change. The notion of “setting the value” of a random variable is known as an intervention. A key reasoning challenge in this setting is that practical causal models often have latent variables and unknown mechanisms: hidden factors influence the observable variables in some way, but the values of the latent variables and the precise causal relationships are unknown. It might seem that reasoning about causal effects with these unknowns is impossible, but Pearl showed that it can be done by rewriting the model into one that no longer depends on the hidden latent variables. In this work, we seek (1) a programming model that enables programmers to express models with latent variables in them; and (2) a formal equational description of a rewriting theory that enables programmers to confidently perform causal reasoning.