diff --git a/Project.toml b/Project.toml index a9d6212..ea5f68a 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ authors = ["Rafael Fourquet "] name = "RandomExtensions" uuid = "fb686558-2515-59ef-acaa-46db3789a887" -version = "0.4.0" +version = "0.4.1" [deps] Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" diff --git a/src/distributions.jl b/src/distributions.jl index 556aa8b..6b4c17c 100644 --- a/src/distributions.jl +++ b/src/distributions.jl @@ -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))