Stan has emerged as the most practical and widely used probabilistic programming language for Bayesian computation. As the capabilities within Stan for further processing of results from probabilistic computations is limited, Stan is often used from a host language such as R or Python through bindings forming an API. However, the structure of these bindings is such that it for many purposes is necessary to replicate the probabilistic model twice: once in Stan for inference, and once in the host language for simulation and prediction. This duplication of work is undesirable for many reasons. This paper investigates a different approach to structuring Stan bindings that mitigating this problem. The central idea is a first-class representation of the Stan model in the host language, allowing models to be constructed programmatically and then used in different ways. The paper demonstrates the ideas in the context of Haskell, but the ideas are applicable to most host languages of interest.
NILSSON, H., NIELSEN, T. A., & STEINITZ, D. (2018). Getting more out of Stan: some ideas from the Haskell bindings