Stream: ideas

Topic: Encode/Decode


view this post on Zulip nandi (Dec 29 2025 at 01:34):

@Luke Boswell mentioned in https://github.com/roc-lang/roc/pull/8788 that static dispatch potentially obsoletes Encode/Decode. Just wondering how we do that going forward. Do we just put encode/decode methods on whatever type we are serializing?

view this post on Zulip Brendan Hansknecht (Dec 29 2025 at 02:38):

I think it is more than encode and decode will be implemented via static dispatch and auto derived. So not really absolute. Just not abilities anymore

view this post on Zulip nandi (Dec 29 2025 at 02:51):

how does that work? lets say I have type Foo and want to serialize, how does auto derive work? Is it similar to derive macro in rust?

view this post on Zulip Brendan Hansknecht (Dec 29 2025 at 03:51):

If it is a structural type. Just doing .decode automatically works. For nominal types, you would define a decode implementation but leave it with no body. In both causes, the compiler will automatically generate.

view this post on Zulip Brendan Hansknecht (Dec 29 2025 at 03:52):

This is compiler magic that is not yet implemented in the new compiler

view this post on Zulip nandi (Dec 30 2025 at 17:19):

I seen that Encode landed in new compiler. Stoked :tada: I'm guessing that means Decode is next? :sweat_smile: :smile:

view this post on Zulip Richard Feldman (Dec 30 2025 at 19:14):

yep, working on it!

view this post on Zulip nandi (Dec 30 2025 at 21:53):

https://github.com/roc-lang/roc/pull/8825 :tada:

view this post on Zulip nandi (Dec 31 2025 at 17:37):

https://github.com/roc-lang/roc/issues/8853


Last updated: Jun 16 2026 at 16:19 UTC