Generate derive keys for tags

This commit is contained in:
Ayaz Hafiz 2022-10-04 16:23:24 -05:00
parent fd54cdfdd1
commit 5eb00c4f94
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
5 changed files with 108 additions and 25 deletions

View file

@ -1,4 +1,4 @@
use roc_module::ident::Lowercase;
use roc_module::ident::{Lowercase, TagName};
use roc_types::subs::{Content, Subs, Variable};
use crate::DeriveError;
@ -42,3 +42,17 @@ pub(crate) fn debug_name_record(fields: &[Lowercase]) -> String {
str.push('}');
str
}
pub(crate) fn debug_name_tag(tags: &[(TagName, u16)]) -> String {
let mut str = String::from('[');
tags.iter().enumerate().for_each(|(i, (tag, arity))| {
if i > 0 {
str.push(',');
}
str.push_str(tag.0.as_str());
str.push(' ');
str.push_str(&arity.to_string());
});
str.push(']');
str
}