[Haskell-cafe] Explicit approach to lazy effects For probability monad?
Benjamin Redelings
benjamin.redelings at gmail.com
Thu Nov 7 17:04:36 UTC 2019
Hi Sandra,
Thank you for the references!
On 10/15/19 11:10 AM, Sandra Dylus wrote:
> if you’re explicitly interested in sharing computations (rather than only modelling non-strictness) then the following approach by Fisher, Kiselyov and Shan might be of interest.
>
> http://homes.sice.indiana.edu/ccshan/rational/S0956796811000189a.pdf (Purely functional lazy nondeterministic programming)
>
> The are modelling the functional logic language Curry, but have also some remarks about modelling a lazy probabilistic language with their approach.
> If you’re not interested in the sharing part of laziness, the paper might be a good first starting point nonetheless. They use a deep monadic embedding that you can use to model non-strictness. Other papers that use such an encoding are the following.
Their function 'share :: m a -> m (m a)' is interesting: I think the
double wrapping m (m a) suggests how one could handle lazy effects in a
monad.
A function (a->b) would get lifted to (m a -> m (m b)).
(i) the input changes from a to (m a) so that the function itself can
decide whether to include the effect of the input into the output
(ii) the output changes from b to m (m b) so that it still has type (m
b) after being unwrapped by the monad.
For example, if g takes type (m b) as input, then:
do
x <- f args -- if f has return type (m b) then x has type b
y <- g x -- but x needs to have type (m b) here
return y
-BenRI
> http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.192.7153&rep=rep1&type=pdf#page=8 (Transforming Functional Logic Programs into Monadic Functional Programs)
> http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.134.9706&rep=rep1&type=pdf (Verifying Haskell Programs Using Constructive Type Theory)
>
> Best regards
> Sandra
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20191107/90454595/attachment.html>
More information about the Haskell-Cafe
mailing list