# StaticArrays: Sub-typing from FieldVector

**URL:** <https://discourse.julialang.org/t/staticarrays-sub-typing-from-fieldvector/83591>\
**Category:** New to Julia\
**Tags:** question, staticarrays\
**Created:** [July 1, 2022, 12:05am UTC](https://discourse.julialang.org/t/staticarrays-sub-typing-from-fieldvector/83591 "2022-07-01T00:05:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mfiano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mfiano/32/37565_2.png) [@mfiano](https://discourse.julialang.org/u/mfiano)\
**Post date:** [July 1, 2022, 12:05am UTC](https://discourse.julialang.org/t/staticarrays-sub-typing-from-fieldvector/83591/1 "2022-07-01T00:05:31Z")

</div>

New to Julia for serious programming, only having dabbled with the REPL for the last 7 years. I’m interested in using StaticArrays to experiment with. My plan is to create an abstract subtype of `FieldVector`:

```julia
module MyMod

import StaticArrays as SA

abstract type MVector{N,T<:AbstractFloat} <: SA.FieldVector{N,T} end

end

```

and then define concrete sub-types of this. The reason why I want to sub-type from `FieldVector` is because there are cases where I want to provide documentation specific to my problem domain, without committing type piracy.

My question is, how can I, for example, create a `Vector3` concrete subtype of my custom `MVector` abstract type, such that the `{N,T<:AbstractFloat}` parameters are encoded into the type definition and passed to the abstract type correctly. I want to specifically avoid type annotations in constructor call sites. I have tried several incantations on writing such a struct definition, and all I get is a not-very-useful:

> ERROR: LoadError: invalid subtyping in definition of Vector3

Any help would be appreciated showing me how to write this subtype correctly. Thanks!

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [July 1, 2022, 2:33am UTC](https://discourse.julialang.org/t/staticarrays-sub-typing-from-fieldvector/83591/2 "2022-07-01T02:33:42Z")

</div>

You want a concrete, parametric type, probably, like:

```julia
struct Vec3{T} <: FieldVector{3,T}
  x::T
  y::T
  z::T
end

```

---

<div class="post-metadata">

**Author:** ![mfiano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mfiano/32/37565_2.png) [@mfiano](https://discourse.julialang.org/u/mfiano)\
**Post date:** [July 1, 2022, 2:47am UTC](https://discourse.julialang.org/t/staticarrays-sub-typing-from-fieldvector/83591/3 "2022-07-01T02:47:43Z")

</div>

Thank you very much!
