A categorical approach to probability theory