mollusk 0e4acfb8f2 fix incorrect folder name for julia-0.6.x
Former-commit-id: ef2c7401e0876f22d2f7762d182cfbcd5a7d9c70
2018-06-11 03:28:36 -07:00

23 lines
901 B
Julia

# This file is a part of Julia. License is MIT: https://julialang.org/license
## numeric/object traits
# trait for objects that have an ordering
abstract type TypeOrder end
struct HasOrder <: TypeOrder end
struct Unordered <: TypeOrder end
TypeOrder(instance) = TypeOrder(typeof(instance))
TypeOrder(::Type{<:Real}) = HasOrder()
TypeOrder(::Type{<:Any}) = Unordered()
# trait for objects that support arithmetic
abstract type TypeArithmetic end
struct ArithmeticRounds <: TypeArithmetic end # least significant bits can be lost
struct ArithmeticOverflows <: TypeArithmetic end # most significant bits can be lost
struct ArithmeticUnknown <: TypeArithmetic end
TypeArithmetic(instance) = TypeArithmetic(typeof(instance))
TypeArithmetic(::Type{<:AbstractFloat}) = ArithmeticRounds()
TypeArithmetic(::Type{<:Integer}) = ArithmeticOverflows()
TypeArithmetic(::Type{<:Any}) = ArithmeticUnknown()