Skip to content

Commit

Permalink
add Make(...) constructor (w/o type params), like the default make(...)
Browse files Browse the repository at this point in the history
  • Loading branch information
rfourquet committed Sep 22, 2020
1 parent 71c3edc commit 42063bf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
authors = ["Rafael Fourquet <fourquet.rafael@gmail.com>"]
name = "RandomExtensions"
uuid = "fb686558-2515-59ef-acaa-46db3789a887"
version = "0.4.0"
version = "0.4.1"

[deps]
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Expand Down
10 changes: 9 additions & 1 deletion src/distributions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,21 @@ Make1{T}(x) where {T} = Make{T}(x)
Make2{T}(x, y) where {T} = Make{T}(x, y)
Make3{T}(x, y, z) where {T} = Make{T}(x, y, z)

# default maketype & make
# default maketype & make & Make(...)

# Make(...) is not meant to be specialized, i.e. Make(a, b, c) always create a Make3,
# and is equal to the *default* make(...)
# (it's a fall-back for client code which can help break recursivity)
# TODO: add tests for Make(...)

maketype(::Type{T}, x...) where {T} = T

Make(::Type{T}, x...) where {T} = Make{maketype(T, x...)}(x...)
make(::Type{T}, x...) where {T} = Make{maketype(T, x...)}(x...)

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

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

2 comments on commit 42063bf

@rfourquet
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/21794

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.4.1 -m "<description of version>" 42063bf76e9fbd84acbf97fc4606b27d67afc628
git push origin v0.4.1

Please sign in to comment.