# Parametric types help

**URL:** https://discourse.julialang.org/t/parametric-types-help/54226
**Category:** New to Julia
**Created:** [January 29, 2021, 8:48pm UTC](https://discourse.julialang.org/t/parametric-types-help/54226 "2021-01-29T20:48:54Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![ohmsweetohm1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ohmsweetohm1/32/49126_2.png) [@ohmsweetohm1](https://discourse.julialang.org/u/ohmsweetohm1)
#### Post date: [January 29, 2021, 8:48pm UTC](https://discourse.julialang.org/t/parametric-types-help/54226/1 "2021-01-29T20:48:54Z")

</div>

This does work:

```julia
abstract type AbstractBar end

struct Foo{T <: Real,V <: AbstractBar}
    bar::Vector{V}
    t::Vector{T}
end

struct Bar <: AbstractBar
    b::Float64
end

Foo{T}() where {T} = Foo{T,Bar}(Bar[], T[])
Foo() = Foo{Float64,Bar}(Bar[], Float64[])

```

```julia
julia> Foo()
Foo{Float64,Bar}(Bar[], Float64[])

julia> Foo{Int64}()
Foo{Int64,Bar}(Bar[], Int64[])

```

This does not work:

```julia
abstract type AbstractBar end

struct Foo{V <: AbstractBar, T <: Real}
    bar::Vector{V}
    t::Vector{T}
end

struct Bar <: AbstractBar
    b::Float64
end

Foo{T}() where {T} = Foo{Bar,T}(Bar[], T[])
Foo() = Foo{Bar,Float64}(Bar[], Float64[])

```

```julia
julia> Foo()
Foo{Bar,Float64}(Bar[], Float64[])

julia> Foo{Int64}()
ERROR: TypeError: in Foo, in V, expected V<:AbstractBar, got Type{Int64}

```

What am I missing here?

---

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [January 29, 2021, 10:05pm UTC](https://discourse.julialang.org/t/parametric-types-help/54226/2 "2021-01-29T22:05:49Z")

</div>

You can’t re-order type parameters.

> [@ohmsweetohm1](#):
>
> ```julia
> julia> Foo{Int64}()
> ERROR: TypeError: in Foo, in V, expected V<:AbstractBar, got Type{Int64}
> 
> ```

You can’t do this because `Foo{X}` is an abstract type `Foo{X,T}`:

```julia
julia> Foo{Bar}
Foo{Bar,T} where T<:Real

```

So `Foo{Int}` will fail because your `Foo` type requires the _first_ type parameter to be a subtype of `AbstractBar`.
