------
-- This is the continuation monad.
------
type E x = ((x -> Double) -> Double)
return :: x -> E x
return x p = p x
-- Here, we have the following types.
-- w :: (x -> Double) -> Double
-- k :: x -> ((y -> Double) -> Double)
-- q :: y -> Double
(>>=) :: E x -> (x -> E y) -> E y
(w >>= k) q = w (\x -> k x q)
References.
- The Expectation Monad in Quantum Foundations (Jacobs, Mandemaker, 2011). There is a correspondence between EMod(Conv(DX,I),I) and EA(Pow(X),I).
- Stochastic lambda calculus and monads of probability distributions (Ramsey, Pfeffer, 2002)] implements the expectation monad in Haskell.
Tags: continuation monad.