# How to express one type related to another

**URL:** https://discourse.julialang.org/t/how-to-express-one-type-related-to-another/103416
**Category:** General Usage
**Created:** [August 31, 2023, 5:53pm UTC](https://discourse.julialang.org/t/how-to-express-one-type-related-to-another/103416 "2023-08-31T17:53:40Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![mikmoore](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mikmoore/32/31109_2.png) [@mikmoore](https://discourse.julialang.org/u/mikmoore)
#### Post date: [August 31, 2023, 6:06pm UTC](https://discourse.julialang.org/t/how-to-express-one-type-related-to-another/103416/4 "2023-08-31T18:06:04Z")

</div>

You’ll ultimately need to use something like the the suggestion above, with “redundant” type parameters. You can use constructors (especially inner constructors) to perform the proper calculations and ensure valid combinations.

See recent discussion on [Simple compile-time evaluation for struct types](https://discourse.julialang.org/t/simple-compile-time-evaluation-for-struct-types/103326/1).

Here’s an example

```julia
struct C{T, S}
    foo::S

    function C(foo::T) where T
        S = promote_type(Float32, T) # calculation to determine S
        S <: Real || error("computed unusable type parameter S=$S") # validate S
        return new{T, S}(convert(S, foo))
    end
end

```

---

_[View the full topic](https://discourse.julialang.org/t/how-to-express-one-type-related-to-another/103416)._
