@@ -3,34 +3,47 @@ struct Bind{M,K} <: AbstractMeasure
3
3
k:: K
4
4
end
5
5
6
- export ↣
7
6
8
7
"""
9
- If
10
- - μ is an `AbstractMeasure` or satisfies the Measure interface, and
11
- - k is a function taking values from the support of μ and returning a measure
8
+ mbind(k, μ)::AbstractMeasure
9
+
10
+ Given
11
+
12
+ - a measure μ
13
+ - a kernel function k that takes values from the support of μ and returns a
14
+ measure
12
15
13
- Then `μ ↣ k` is a measure, called a *monadic bind*. In a
14
- probabilistic programming language like Soss.jl, this could be expressed as
16
+ The *monadic bind* operation `mbind(k, μ)` returns is a new measure.
15
17
16
- Note that bind is usually written `>>=`, but this symbol is unavailable in Julia.
18
+ A monadic bind ofen written as `>>=` (e.g. in Haskell), but this symbol is
19
+ unavailable in Julia.
17
20
18
21
```
19
- bind = @model μ,k begin
20
- x ~ μ
21
- y ~ k(x)
22
- return y
22
+ μ = StdExponential()
23
+ ν = mbind(μ) do scale
24
+ pushfwd(Base.Fix1(*, scale), StdNormal())
23
25
end
24
26
```
25
-
26
- See also `bind` and `Bind`
27
27
"""
28
- ↣ (μ, k) = bind (μ, k)
29
-
30
- bind (μ, k) = Bind (μ, k)
28
+ mbind (k, μ) = Bind (μ, k)
29
+ export mbind
31
30
32
31
function Base. rand (rng:: AbstractRNG , :: Type{T} , d:: Bind ) where {T}
33
32
x = rand (rng, T, d. μ)
34
33
y = rand (rng, T, d. k (x))
35
34
return y
36
35
end
36
+
37
+
38
+ # ToDo: Remove `bind` (breaking).
39
+ @noinline function bind (μ, k)
40
+ Base. depwarn (" `foo(μ, k)` is deprecated, use `mbind(k, μ)` instead." , :bind )
41
+ mbind (k, μ)
42
+ end
43
+
44
+
45
+ # ToDo: Remove `↣` (breaking): It looks too similar to the `>=>` "fish"
46
+ # operator (e.g. in Haskell) that is typically understood to take two monadic
47
+ # functions as an argument, while a bind take a monad and a monadic functions.
48
+ @deprecate ↣ (μ, k) mbind (μ, k)
49
+ export ↣
0 commit comments