Stream: wasmtime

Topic: Recursive Types


view this post on Zulip Ashanti Mutinta (Aug 11 2025 at 19:58):

What is the best way to design recursive types in the wit file? I think there is a proposal coming soon

view this post on Zulip Joel Dice (Aug 11 2025 at 22:06):

This issue discusses a couple of workarounds: index-based and resource-based.

There are quite a few cases that require defining recursive values: package wit:json@0.1.0; interface types { variant json { null, boolean(bool), number(float64), string(string), array(list<json>),...

view this post on Zulip Ashanti Mutinta (Aug 13 2025 at 19:34):

Nice this is awesome perfect.

I have a tangential question but is it possible to have a resource defined in a record type to be then used as an input to export function?

view this post on Zulip Joel Dice (Aug 13 2025 at 19:41):

What do you mean by a resource defined in a record type? Can you give an example?

view this post on Zulip Joel Dice (Aug 13 2025 at 19:44):

If you're wondering whether you can export a function that has a parameter whose type is that of an exported resource (or that of a record that has a field whose type is that of an exported resource, etc.), then yes, that should work fine.

view this post on Zulip Ashanti Mutinta (Aug 13 2025 at 19:46):

Oh nice! I

was mostly wondering about an export function which parameter is an imported type or contains one.

I guess I have a similar use case as the one described in the link but would love to do all my serde processesing in the host(using the resource hack)

view this post on Zulip Joel Dice (Aug 13 2025 at 20:22):

Yeah, exported functions should be able to refer to imported types, but not the other way around: https://github.com/WebAssembly/component-model/issues/272

The Component Model does not currently allow you to refer to exported types in imports, which feels asymmetric given that one can easily refer to imported types in exports. This becomes a practical...

Last updated: Dec 06 2025 at 06:05 UTC