Skip to content

Commit 42063bf

Browse files
committed
add Make(...) constructor (w/o type params), like the default make(...)
1 parent 71c3edc commit 42063bf

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
authors = ["Rafael Fourquet <fourquet.rafael@gmail.com>"]
22
name = "RandomExtensions"
33
uuid = "fb686558-2515-59ef-acaa-46db3789a887"
4-
version = "0.4.0"
4+
version = "0.4.1"
55

66
[deps]
77
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

src/distributions.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,21 @@ Make1{T}(x) where {T} = Make{T}(x)
4242
Make2{T}(x, y) where {T} = Make{T}(x, y)
4343
Make3{T}(x, y, z) where {T} = Make{T}(x, y, z)
4444

45-
# default maketype & make
45+
# default maketype & make & Make(...)
46+
47+
# Make(...) is not meant to be specialized, i.e. Make(a, b, c) always create a Make3,
48+
# and is equal to the *default* make(...)
49+
# (it's a fall-back for client code which can help break recursivity)
50+
# TODO: add tests for Make(...)
51+
4652
maketype(::Type{T}, x...) where {T} = T
4753

54+
Make(::Type{T}, x...) where {T} = Make{maketype(T, x...)}(x...)
4855
make(::Type{T}, x...) where {T} = Make{maketype(T, x...)}(x...)
4956

5057
# make(x) is defined in sampling.jl, and is a special case wrapping already valid
5158
# distributions (explicit or implicit)
59+
Make(x1, x2, xs...) = Make{maketype(x1, x2, xs...)}(x1, x2, xs...)
5260
make(x1, x2, xs...) = Make{maketype(x1, x2, xs...)}(x1, x2, xs...)
5361

5462
find_deduced_type(::Type{T}, ::X, ) where {T,X} = deduce_type(T, gentype(X))

0 commit comments

Comments
 (0)