I have something like
# Define a Person type that can be encoded as a JSON object
Person := [New({ name : Str, age : U64 })].{
# Custom encode method for Person - encodes as JSON object
encode : Person, JsonFormat -> List(U8)
encode = |self, fmt| {
# Get the inner record via pattern match
match self {
New({ name, age }) => {
I have a dilemma because I don't like naming my variants the same names as my types but if I use something like New, then that is what I have to pattern match on which doesn't feel right either. Anyone have any insights?
I think nominal records work already - do they not?
(basically just omit the tag altogether)
Possibly lol Im not sure, can you define methods on nominal records? Sorry for my ignorance, still trying to figure out the diff of what is missing from my mind and what is missing from compiler
just filed https://github.com/roc-lang/roc/issues/8834 since there doesn't appear to be a way to construct nominal records
on it!
https://github.com/roc-lang/roc/issues/8866 seems related
Last updated: Jun 16 2026 at 16:19 UTC