# LoadError: TypeError: Type{...} expression: expected UnionAll, got TypeVar

**URL:** <https://discourse.julialang.org/t/loaderror-typeerror-type-expression-expected-unionall-got-typevar/7646>\
**Category:** General Usage\
**Created:** [December 9, 2017, 6:35am UTC](https://discourse.julialang.org/t/loaderror-typeerror-type-expression-expected-unionall-got-typevar/7646 "2017-12-09T06:35:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Qiyamah](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/qiyamah/32/2660_2.png) [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Post date:** [December 9, 2017, 6:35am UTC](https://discourse.julialang.org/t/loaderror-typeerror-type-expression-expected-unionall-got-typevar/7646/1 "2017-12-09T06:35:38Z")

</div>

Hi everyone,

I was writing an Option Monad, and this is what i get from the following line:

```nohighlight
m_join{T1<:Option,T2<:Option,T}(x::T1{T2{T}}) = get(None{T}(),x)

```

and structure of Option is as follows:

```nohighlight
    abstract type Option{T} <: Monad end

    type Some{T} <: Option{T}
        value::T
    end

    type None{T} <: Option{T}
    end

```

I can’t figure out why that error is given? Can someone explain it to me? Thanks

---

<div class="post-metadata">

**Author:** ![Qiyamah](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/qiyamah/32/2660_2.png) [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Post date:** [December 9, 2017, 6:47am UTC](https://discourse.julialang.org/t/loaderror-typeerror-type-expression-expected-unionall-got-typevar/7646/2 "2017-12-09T06:47:02Z")

</div>

If I try the following:

```nohighlight
m_join{T}(x::Option{Option{T}}) = get(None{T}(),x)

```

It gives me the following error:

```julia
ERROR: LoadError: MethodError: no method matching m_join(::JHC.Utility.Monads.Some{JHC.Utility.Monads.Some{Int64}})
Closest candidates are:
  m_join(!Matched::JHC.Utility.Monads.TypedFun{JHC.Utility.Monads.TypedFun{T}}) where T at /home/xxx/Projects/JHC/src/Utility/Monads.jl:55
  m_join(!Matched::JHC.Utility.Monads.Option{JHC.Utility.Monads.Option{T}}) where T at /home/xxx/Projects/JHC/src/Utility/Monads.jl:132

```

---

<div class="post-metadata">

**Author:** ![lbittarello](https://avatars.discourse-cdn.com/v4/letter/l/ed655f/32.png) [@lbittarello](https://discourse.julialang.org/u/lbittarello)\
**Post date:** [December 9, 2017, 5:56pm UTC](https://discourse.julialang.org/t/loaderror-typeerror-type-expression-expected-unionall-got-typevar/7646/3 "2017-12-09T17:56:43Z")

</div>

This approach seems to work:

```julia
function m_join(x::T1) where {T1 <: Option{T2}} where {T2 <: Option{T}} where {T}
    get(None{T}(), x)
end

```

By the way, the syntax `f{T}(x::T)` is being deprecated in favor of `f(x::T) where {T}`.
