Composing inference algorithms as program transformations