# Are modules intended to work as type parameters?

**URL:** <https://discourse.julialang.org/t/are-modules-intended-to-work-as-type-parameters/130267>\
**Category:** Internals & Design\
**Tags:** parametric-types\
**Created:** [June 27, 2025, 3:36am UTC](https://discourse.julialang.org/t/are-modules-intended-to-work-as-type-parameters/130267 "2025-06-27T03:36:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)\
**Post date:** [June 27, 2025, 3:36am UTC](https://discourse.julialang.org/t/are-modules-intended-to-work-as-type-parameters/130267/1 "2025-06-27T03:36:16Z")

</div>

Currently these are documented as valid type parameters:

> Both abstract and concrete types can be parameterized by other types. They can also be parameterized by symbols, by values of any type for which [`isbits`](https://docs.julialang.org/en/v1/base/base/#Base.isbits) returns true (essentially, things like numbers and bools that are stored like C types or `struct` s with no pointers to other objects), and also by tuples thereof.

That is seemingly equivalent to this check:

```julia
function validparameter(x)
  x isa Type || x isa Symbol || isbits(x) ||
  # () isbits so don't need isempty check
  (x isa Tuple && all(y -> (y isa Symbol || isbits(y)), x))
end

```

and some examples:

```julia
julia> validparameter.([Int :num () (:num, ()) (Int, Int) "num" Base])
1×7 BitMatrix:
 1 1 1 1 0 0 0

```

Which mostly behave as expected when attempting to use as type parameters:

```julia
julia> Val.([Int :num () (:num, ())])
1×4 Matrix{Val}:
 Val{Int64}() Val{:num}() Val{()}() Val{(:num, ())}()

julia> Val((Int, Int))
ERROR: TypeError: in Type, in parameter, expected Type, got a value of type Tuple{DataType, DataType}
...
julia> Val("num")
ERROR: TypeError: in Type, in parameter, expected Type, got a value of type String
...

```

Except for the module:

```julia
julia> Val(Base)
Val{Base}()

```

It’s useful for dispatch, but is this intentional and stable?

---

<div class="post-metadata">

**Author:** ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Post date:** [June 27, 2025, 3:43am UTC](https://discourse.julialang.org/t/are-modules-intended-to-work-as-type-parameters/130267/2 "2025-06-27T03:43:08Z")

</div>

Feature added in this PR:

- [Allow Module as type parameters by Keno · Pull Request #47749 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/pull/47749)

Relevant doc issue on Github bug tracker:

- [Clarify expecations for valid `Val` parameters · Issue #53734 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues/53734)

---

<div class="post-metadata">

**Author:** ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)\
**Post date:** [June 27, 2025, 3:45am UTC](https://discourse.julialang.org/t/are-modules-intended-to-work-as-type-parameters/130267/3 "2025-06-27T03:45:30Z")

</div>

That was a record-fast solution for me. Could not Google that out for my life.
