# Confused by "Type"

**URL:** https://discourse.julialang.org/t/confused-by-type/131714
**Category:** General Usage
**Created:** [August 19, 2025, 4:15pm UTC](https://discourse.julialang.org/t/confused-by-type/131714 "2025-08-19T16:15:13Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![alan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alan/32/15970_2.png) [@alan](https://discourse.julialang.org/u/alan)
#### Post date: [August 19, 2025, 4:15pm UTC](https://discourse.julialang.org/t/confused-by-type/131714/1 "2025-08-19T16:15:13Z")

</div>

I’m confused by this snippet from `https://docs.julialang.org/en/v1/manual/interfaces/#man-interface-array`:

```julia-auto
julia> struct SquaresVector <: AbstractArray{Int, 1}
           count::Int
       end

julia> Base.IndexStyle(::Type{<:SquaresVector}) = IndexLinear()

```

Why do we need `::Type{<:SquaresVector})` in the definition of `Base.IndexStyle`? I’d have written `::SquaresVector` instead, and this simpler definition also seems to work. The code listed above seems to refer to a subtype of SquaresVector. But this is a concrete type, and I thought it was illegal to derive a new type from a concrete type.

---

<div class="post-metadata">

### Author: ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)
#### Post date: [August 19, 2025, 4:36pm UTC](https://discourse.julialang.org/t/confused-by-type/131714/2 "2025-08-19T16:36:11Z")

</div>

I wrote that, and did so intentionally. You’re right that it’s not needed for `SquaresVector`, but you do still need to use `::Type{SquaresVector}`. The vast vast majority of AbstractArray subtypes will have type parameters… and it’s in that case where you’d need the `<:` clause.

You don’t just want to define this for _values_ of type `::SquaresVector`, however, because `IndexStyle` is a trait for the type itself (and there are some callers that will just ask for `IndexStyle(SquaresVector)`.

---

<div class="post-metadata">

### Author: ![eldee](https://avatars.discourse-cdn.com/v4/letter/e/b5a626/32.png) [@eldee](https://discourse.julialang.org/u/eldee)
#### Post date: [August 19, 2025, 4:59pm UTC](https://discourse.julialang.org/t/confused-by-type/131714/3 "2025-08-19T16:59:41Z")

</div>

> [@alan](#):
>
> I’d have written `::SquaresVector` instead, and this simpler definition also seems to work

Something to also take into account is that by default

```julia
IndexStyle(A::AbstractArray) = IndexStyle(typeof(A))

```

So if you use

```julia-auto
Base.IndexStyle(::Type{<:SquaresVector}) = IndexLinear()

```

you automatically also change `Base.IndexStyle(::SquaresVector)`. But the converse is not true:

```julia-repl
julia> struct SquaresVector <: AbstractArray{Int, 1}
           count::Int
       end

julia> Base.IndexStyle(::SquaresVector) = IndexLinear()

julia> s = SquaresVector(4);

julia> IndexStyle(s)
IndexLinear()

julia> IndexStyle(SquaresVector)
IndexCartesian()

```

---

<div class="post-metadata">

### Author: ![alan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alan/32/15970_2.png) [@alan](https://discourse.julialang.org/u/alan)
#### Post date: [August 19, 2025, 5:12pm UTC](https://discourse.julialang.org/t/confused-by-type/131714/4 "2025-08-19T17:12:14Z")

</div>

Why do you need the `<:` operator? Seems to work without it:

```julia-auto
julia> struct SquaresVector <: AbstractArray{Int, 1}
                  count::Int
              end

julia> Base.IndexStyle(::Type{SquaresVector}) = IndexLinear()

julia> s = SquaresVector(3);

julia> IndexStyle(s)
IndexLinear()

julia> IndexStyle(SquaresVector)
IndexLinear()

```

---

<div class="post-metadata">

### Author: ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)
#### Post date: [August 19, 2025, 5:34pm UTC](https://discourse.julialang.org/t/confused-by-type/131714/5 "2025-08-19T17:34:28Z")

</div>

That’s what I first thought you were talking about — the `<:` is only unnecessary if your type doesn’t have parameters. Most `AbstractArray` subtypes do have parameters, however, and in that case it’s needed because you want to capture all possible parameterizations.
