I have not been able to find/understand what the plans are for Roc syntax in a world where Abilities and Opaque types are not longer part of the language. Currently in my project have have places with code like this :
JsonBody a := {
jsonrpc : Str,
method : Method,
params : a,
id : Str,
}
implements [Encoding]
This uses both Abilities and Opaque types, in other places I use the support for phantom types in opaque types. I would be glad if someone could show me a code example on how to express that my custom type supports Encoding and also how phantom types would look like in custom types.
From what I understand, Custom types and Opaque types are essentially identical. Custom types just enable exposing internals if wanted.
So I would mostly view Opaque -> Custom as a rename of a feature with some minor changes
They should support phantom types in the exact same way
how to express that my custom type supports Encoding
This you can't do. At least not concretely like you could with abilities
In the new static dispatch world, interfaces are automatically implemented. If a custom type exposes functions that match encode, that custom type implements the encode interface. This is essentially identical to how interfaces work in golang (which might help give you bigger context/reference)
So you would probably expose all the encode related functions and then write a test that uses your custom type with encode to ensure everything works.
Ok thanks. Cool that interfaces will work as in golang. I had totally missed that.
Last updated: Jul 06 2025 at 12:14 UTC