Semantics for probabilistic programming: higher-order functions, continuous distributions, and soft constraints