# Combining SimpleTraits.jl traits on one type

**URL:** https://discourse.julialang.org/t/combining-simpletraits-jl-traits-on-one-type/73644
**Category:** General Usage
**Tags:** traits
**Created:** [December 26, 2021, 2:40pm UTC](https://discourse.julialang.org/t/combining-simpletraits-jl-traits-on-one-type/73644 "2021-12-26T14:40:51Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![FMeirinhos](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fmeirinhos/32/19527_2.png) [@FMeirinhos](https://discourse.julialang.org/u/FMeirinhos)
#### Post date: [December 27, 2021, 5:05pm UTC](https://discourse.julialang.org/t/combining-simpletraits-jl-traits-on-one-type/73644/2 "2021-12-27T17:05:15Z")

</div>

From the [README](https://github.com/mauro3/SimpleTraits.jl#details-of-method-dispatch) on `SimpleTraits.jl` it appears dispatching on multiple traits is not yet possible.

However `WhereTraits.jl` [could possibly support it](https://discourse.julialang.org/t/announcing-traits-jl-a-revival-of-julia-traits/35683/5)!

```julia
using WhereTraits

abstract type AbstractA end
abstract type DecoA <: AbstractA end

# A few concrete types
struct A <: AbstractA end
struct A1 <: DecoA end
struct A2 <: DecoA end
struct A3 <: DecoA end

# just some function
f(::AbstractA, x) = x+2
g(::DecoA, x, y) = x+y

is_nice(::Type{<:A1}) = true
is_nice(::Type{<:DecoA}) = false

is_cool(::Type{<:A2}) = true
is_cool(::Type{<:DecoA}) = false

@traits f(a::TA, x) where {TA <: DecoA, is_nice(TA)} = g(a,x,3)
@traits f(a::TA, x) where {TA <: DecoA, is_cool(TA)} = g(a,x,5)
@traits f(a::TA, x) where {TA <: DecoA, !is_cool(TA), !is_nice(TA)} = "without this the multiple dispatch is ill-defined for `A3`"

@show f(A(),0)
@show f(A1(),0)
@show f(A2(),0)
@show f(A3(),0)

```

---

_[View the full topic](https://discourse.julialang.org/t/combining-simpletraits-jl-traits-on-one-type/73644)._
