I'm not sure what you want, either. How about this? julia> type BadInt{X} end
julia> BadInt{3}() BadInt{3}() julia> f{X}(::Type{BadInt{X}}, y) = X - y f (generic function with 1 method) julia> f(BadInt{10}, 3) 7 julia> f{X}(::BadInt{X}, y) = X - y f (generic function with 2 methods) julia> f(BadInt{10}(), 3) 7 On Wed, Dec 9, 2015 at 8:56 AM, Eric Forgy <eric.fo...@gmail.com> wrote: > Not sure I follow, but does this help? > > julia> type BadInt > end > > julia> bi = BadInt() > BadInt() > > julia> typeof(bi) > BadInt > > > On Wednesday, December 9, 2015 at 9:46:01 PM UTC+8, milktrader wrote: >> >> How do you create an instance of type BadInt then? >> >> On Wednesday, December 9, 2015 at 7:01:25 AM UTC-5, milktrader wrote: >>> >>> Trying to wrap my mind around singleton types to see if they might be >>> useful for something I'm working on, but running into some confusion. Here >>> is an example that I started working with: >>> >>> julia> type BadInt >>> end >>> >>> julia> import Base.+ >>> >>> julia> +(x::BadInt, y::Int64) = x - y >>> + (generic function with 172 methods) >>> >>> julia> BadInt() = 2 >>> BadInt >>> >>> julia> BadInt + 2 >>> ERROR: MethodError: `+` has no method matching +(::Type{BadInt}, ::Int64) >>> Closest candidates are: >>> +(::Any, ::Any, ::Any, ::Any...) >>> +(::Int64, ::Int64) >>> +(::Complex{Bool}, ::Real) >>> ... >>> >>> As I understand, a singleton type can only take on a single value. >>> What's the utility in supporting this? >>> >>