# How can I express the abstract type of a multi-parameter type that only matches the second parameter

**URL:** <https://discourse.julialang.org/t/how-can-i-express-the-abstract-type-of-a-multi-parameter-type-that-only-matches-the-second-parameter/118405>\
**Category:** General Usage\
**Tags:** question, parametric-types\
**Created:** [August 20, 2024, 6:28am UTC](https://discourse.julialang.org/t/how-can-i-express-the-abstract-type-of-a-multi-parameter-type-that-only-matches-the-second-parameter/118405 "2024-08-20T06:28:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Blumenkranz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/blumenkranz/32/210335_2.png) [@Blumenkranz](https://discourse.julialang.org/u/Blumenkranz)\
**Post date:** [August 20, 2024, 6:28am UTC](https://discourse.julialang.org/t/how-can-i-express-the-abstract-type-of-a-multi-parameter-type-that-only-matches-the-second-parameter/118405/1 "2024-08-20T06:28:13Z")

</div>

If I have a type `VS_Data{DIM,NDF}` and a instance `a::VS_Data{3,2}`. Then we have `isa(a,VS_Data{3})=true` but `isa(a,VS_Data{2})=false`, which implies that `VS_Data{DIM,NDF}<:VS_Data{DIM}`. My question is how can I express the abstract type that only matches the parameter `NDF`?

---

<div class="post-metadata">

**Author:** ![\_bernhard](https://avatars.discourse-cdn.com/v4/letter/_/bc79bd/32.png) [@\_bernhard](https://discourse.julialang.org/u/_bernhard)\
**Post date:** [August 20, 2024, 6:40am UTC](https://discourse.julialang.org/t/how-can-i-express-the-abstract-type-of-a-multi-parameter-type-that-only-matches-the-second-parameter/118405/2 "2024-08-20T06:40:59Z")

</div>

As you discovered, supplying type parameters generally works from left to right.

To work around that, the general syntax applied to your example is

```julia
VS_Data{DIM,2} where DIM

```

---

<div class="post-metadata">

**Author:** ![Blumenkranz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/blumenkranz/32/210335_2.png) [@Blumenkranz](https://discourse.julialang.org/u/Blumenkranz)\
**Post date:** [August 20, 2024, 6:42am UTC](https://discourse.julialang.org/t/how-can-i-express-the-abstract-type-of-a-multi-parameter-type-that-only-matches-the-second-parameter/118405/3 "2024-08-20T06:42:46Z")

</div>

That’s what I want. Thanks a lot!

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [August 20, 2024, 7:28am UTC](https://discourse.julialang.org/t/how-can-i-express-the-abstract-type-of-a-multi-parameter-type-that-only-matches-the-second-parameter/118405/5 "2024-08-20T07:28:01Z")

</div>

> [@\_bernhard](#):
>
> `VS_Data{DIM,2} where DIM`

I wonder if it would be possible to support “currying” of underscores in situations like this:

```julia
VS_Data{_, 2}

```

There has been a long discussion on supporting this for function arguments (e.g. `f(_, x)`), and this would be a nice parallel to that. But perhaps the same problems show up here, like `where` the scope of `_` should end?

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [August 20, 2024, 9:49am UTC](https://discourse.julialang.org/t/how-can-i-express-the-abstract-type-of-a-multi-parameter-type-that-only-matches-the-second-parameter/118405/6 "2024-08-20T09:49:37Z")

</div>

Would it be possible to write a MWE to make it less abstract?

---

<div class="post-metadata">

**Author:** ![\_bernhard](https://avatars.discourse-cdn.com/v4/letter/_/bc79bd/32.png) [@\_bernhard](https://discourse.julialang.org/u/_bernhard)\
**Post date:** [August 20, 2024, 1:49pm UTC](https://discourse.julialang.org/t/how-can-i-express-the-abstract-type-of-a-multi-parameter-type-that-only-matches-the-second-parameter/118405/7 "2024-08-20T13:49:19Z")

</div>

Although this is not really more ergonomic in this simple example, for more complex cases it can be convenient to define an alias with type parameters swapped (or generally, re-ordered) like:

```julia
const VS_DATA_swapped{NDF,DIM} = VS_Data{DIM,NDF} where {DIM,NDF}

```

Edit: for actual usecases `const` is probably a good idea.
