has -> implements

This commit is contained in:
Bryce Miller 2023-05-26 22:59:29 -04:00
parent d3f6277ea3
commit d2503bb9f2
No known key found for this signature in database
GPG Key ID: F1E97BF8DF152350
7 changed files with 33 additions and 33 deletions

View File

@ -134,7 +134,7 @@ impl<'a> Formattable for TypeDef<'a> {
buf.indent(indent);
}
buf.push_str(" has");
buf.push_str(" implements");
if !self.is_multiline() {
debug_assert_eq!(members.len(), 1);

View File

@ -87,7 +87,7 @@ fn derivable_record_ext_flex_var() {
fn derivable_record_ext_flex_able_var() {
check_derivable(
Decoder,
v!({ a: v!(STR), }a has Symbol::DECODE_DECODER ),
v!({ a: v!(STR), }a implements Symbol::DECODE_DECODER ),
DeriveKey::Decoder(FlatDecodableKey::Record(vec!["a".into()])),
);
}
@ -124,8 +124,8 @@ fn record_2_fields() {
derive_test(Decoder, v!({first: v!(STR), second: v!(STR),}), |golden| {
assert_snapshot!(golden, @r###"
# derived for { first : Str, second : Str }
# Decoder { first : val, second : val1 } fmt | fmt implements DecoderFormatting, val has Decoding, val1 implements Decoding
# List U8, fmt -[[custom(22)]]-> { rest : List U8, result : [Err [TooShort], Ok { first : val, second : val1 }] } | fmt implements DecoderFormatting, val has Decoding, val1 implements Decoding
# Decoder { first : val, second : val1 } fmt | fmt implements DecoderFormatting, val implements Decoding, val1 implements Decoding
# List U8, fmt -[[custom(22)]]-> { rest : List U8, result : [Err [TooShort], Ok { first : val, second : val1 }] } | fmt implements DecoderFormatting, val implements Decoding, val1 implements Decoding
# Specialization lambda sets:
# @<1>: [[custom(22)]]
#Derived.decoder_{first,second} =
@ -181,8 +181,8 @@ fn tuple_2_fields() {
derive_test(Decoder, v!((v!(STR), v!(U8),)), |golden| {
assert_snapshot!(golden, @r###"
# derived for ( Str, U8 )*
# Decoder ( val, val1 )* fmt | fmt implements DecoderFormatting, val has Decoding, val1 implements Decoding
# List U8, fmt -[[custom(22)]]-> { rest : List U8, result : [Err [TooShort], Ok ( val, val1 )a] } | fmt implements DecoderFormatting, val has Decoding, val1 implements Decoding
# Decoder ( val, val1 )* fmt | fmt implements DecoderFormatting, val implements Decoding, val1 implements Decoding
# List U8, fmt -[[custom(22)]]-> { rest : List U8, result : [Err [TooShort], Ok ( val, val1 )a] } | fmt implements DecoderFormatting, val implements Decoding, val1 implements Decoding
# Specialization lambda sets:
# @<1>: [[custom(22)]]
#Derived.decoder_(arity:2) =

View File

@ -139,7 +139,7 @@ fn derivable_record_ext_flex_var() {
fn derivable_record_ext_flex_able_var() {
check_derivable(
ToEncoder,
v!({ a: v!(STR), }a has Symbol::ENCODE_TO_ENCODER),
v!({ a: v!(STR), }a implements Symbol::ENCODE_TO_ENCODER),
DeriveKey::ToEncoder(FlatEncodableKey::Record(vec!["a".into()])),
);
}
@ -166,7 +166,7 @@ fn derivable_tag_ext_flex_var() {
fn derivable_tag_ext_flex_able_var() {
check_derivable(
ToEncoder,
v!([ A v!(STR) ]a has Symbol::ENCODE_TO_ENCODER),
v!([ A v!(STR) ]a implements Symbol::ENCODE_TO_ENCODER),
DeriveKey::ToEncoder(FlatEncodableKey::TagUnion(vec![("A".into(), 1)])),
);
}
@ -251,8 +251,8 @@ fn two_field_record() {
derive_test(ToEncoder, v!({ a: v!(U8), b: v!(STR), }), |golden| {
assert_snapshot!(golden, @r###"
# derived for { a : U8, b : Str }
# { a : val, b : val1 } -[[toEncoder_{a,b}(0)]]-> Encoder fmt | fmt implements EncoderFormatting, val has Encoding, val1 implements Encoding
# { a : val, b : val1 } -[[toEncoder_{a,b}(0)]]-> (List U8, fmt -[[custom(2) { a : val, b : val1 }]]-> List U8) | fmt implements EncoderFormatting, val has Encoding, val1 implements Encoding
# { a : val, b : val1 } -[[toEncoder_{a,b}(0)]]-> Encoder fmt | fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding
# { a : val, b : val1 } -[[toEncoder_{a,b}(0)]]-> (List U8, fmt -[[custom(2) { a : val, b : val1 }]]-> List U8) | fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding
# Specialization lambda sets:
# @<1>: [[toEncoder_{a,b}(0)]]
# @<2>: [[custom(2) { a : val, b : val1 }]] | val implements Encoding, val1 implements Encoding
@ -278,8 +278,8 @@ fn two_field_tuple() {
derive_test(ToEncoder, v!((v!(U8), v!(STR),)), |golden| {
assert_snapshot!(golden, @r###"
# derived for ( U8, Str )*
# ( val, val1 )* -[[toEncoder_(arity:2)(0)]]-> Encoder fmt | fmt implements EncoderFormatting, val has Encoding, val1 implements Encoding
# ( val, val1 )a -[[toEncoder_(arity:2)(0)]]-> (List U8, fmt -[[custom(2) ( val, val1 )a]]-> List U8) | fmt implements EncoderFormatting, val has Encoding, val1 implements Encoding
# ( val, val1 )* -[[toEncoder_(arity:2)(0)]]-> Encoder fmt | fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding
# ( val, val1 )a -[[toEncoder_(arity:2)(0)]]-> (List U8, fmt -[[custom(2) ( val, val1 )a]]-> List U8) | fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding
# Specialization lambda sets:
# @<1>: [[toEncoder_(arity:2)(0)]]
# @<2>: [[custom(2) ( val, val1 )*]] | val implements Encoding, val1 implements Encoding
@ -338,8 +338,8 @@ fn tag_one_label_two_args() {
derive_test(ToEncoder, v!([A v!(U8) v!(STR)]), |golden| {
assert_snapshot!(golden, @r###"
# derived for [A U8 Str]
# [A val val1] -[[toEncoder_[A 2](0)]]-> Encoder fmt | fmt implements EncoderFormatting, val has Encoding, val1 implements Encoding
# [A val val1] -[[toEncoder_[A 2](0)]]-> (List U8, fmt -[[custom(4) [A val val1]]]-> List U8) | fmt implements EncoderFormatting, val has Encoding, val1 implements Encoding
# [A val val1] -[[toEncoder_[A 2](0)]]-> Encoder fmt | fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding
# [A val val1] -[[toEncoder_[A 2](0)]]-> (List U8, fmt -[[custom(4) [A val val1]]]-> List U8) | fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding
# Specialization lambda sets:
# @<1>: [[toEncoder_[A 2](0)]]
# @<2>: [[custom(4) [A val val1]]] | val implements Encoding, val1 implements Encoding
@ -366,8 +366,8 @@ fn tag_two_labels() {
|golden| {
assert_snapshot!(golden, @r###"
# derived for [A U8 Str U16, B Str]
# [A val val1 val1, B val1] -[[toEncoder_[A 3,B 1](0)]]-> Encoder fmt | fmt implements EncoderFormatting, val has Encoding, val1 implements Encoding
# [A val val1 val1, B val1] -[[toEncoder_[A 3,B 1](0)]]-> (List U8, fmt -[[custom(6) [A val val1 val1, B val1]]]-> List U8) | fmt implements EncoderFormatting, val has Encoding, val1 implements Encoding
# [A val val1 val1, B val1] -[[toEncoder_[A 3,B 1](0)]]-> Encoder fmt | fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding
# [A val val1 val1, B val1] -[[toEncoder_[A 3,B 1](0)]]-> (List U8, fmt -[[custom(6) [A val val1 val1, B val1]]]-> List U8) | fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding
# Specialization lambda sets:
# @<1>: [[toEncoder_[A 3,B 1](0)]]
# @<2>: [[custom(6) [A val val1 val1, B val1]]] | val implements Encoding, val1 implements Encoding
@ -402,8 +402,8 @@ fn recursive_tag_union() {
|golden| {
assert_snapshot!(golden, @r###"
# derived for [Cons U8 $rec, Nil] as $rec
# [Cons val val1, Nil] -[[toEncoder_[Cons 2,Nil 0](0)]]-> Encoder fmt | fmt implements EncoderFormatting, val has Encoding, val1 implements Encoding
# [Cons val val1, Nil] -[[toEncoder_[Cons 2,Nil 0](0)]]-> (List U8, fmt -[[custom(4) [Cons val val1, Nil]]]-> List U8) | fmt implements EncoderFormatting, val has Encoding, val1 implements Encoding
# [Cons val val1, Nil] -[[toEncoder_[Cons 2,Nil 0](0)]]-> Encoder fmt | fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding
# [Cons val val1, Nil] -[[toEncoder_[Cons 2,Nil 0](0)]]-> (List U8, fmt -[[custom(4) [Cons val val1, Nil]]]-> List U8) | fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding
# Specialization lambda sets:
# @<1>: [[toEncoder_[Cons 2,Nil 0](0)]]
# @<2>: [[custom(4) [Cons val val1, Nil]]] | val implements Encoding, val1 implements Encoding

View File

@ -102,7 +102,7 @@ fn derivable_record_ext_flex_var() {
fn derivable_record_ext_flex_able_var() {
check_derivable(
Hash,
v!({ a: v!(STR), }a has Symbol::DECODE_DECODER ),
v!({ a: v!(STR), }a implements Symbol::DECODE_DECODER ),
DeriveKey::Hash(FlatHashKey::Record(vec!["a".into()])),
);
}
@ -129,7 +129,7 @@ fn derivable_tag_ext_flex_var() {
fn derivable_tag_ext_flex_able_var() {
check_derivable(
Hash,
v!([ A v!(STR) ]a has Symbol::ENCODE_TO_ENCODER),
v!([ A v!(STR) ]a implements Symbol::ENCODE_TO_ENCODER),
DeriveKey::Hash(FlatHashKey::TagUnion(vec![("A".into(), 1)])),
);
}
@ -197,8 +197,8 @@ fn two_field_record() {
derive_test(Hash, v!({ a: v!(U8), b: v!(STR), }), |golden| {
assert_snapshot!(golden, @r###"
# derived for { a : U8, b : Str }
# hasher, { a : a, b : a1 } -[[hash_{a,b}(0)]]-> hasher | a implements Hash, a1 has Hash, hasher implements Hasher
# hasher, { a : a, b : a1 } -[[hash_{a,b}(0)]]-> hasher | a implements Hash, a1 has Hash, hasher implements Hasher
# hasher, { a : a, b : a1 } -[[hash_{a,b}(0)]]-> hasher | a implements Hash, a1 implements Hash, hasher implements Hasher
# hasher, { a : a, b : a1 } -[[hash_{a,b}(0)]]-> hasher | a implements Hash, a1 implements Hash, hasher implements Hasher
# Specialization lambda sets:
# @<1>: [[hash_{a,b}(0)]]
#Derived.hash_{a,b} =
@ -214,8 +214,8 @@ fn two_element_tuple() {
derive_test(Hash, v!((v!(U8), v!(STR),)), |golden| {
assert_snapshot!(golden, @r###"
# derived for ( U8, Str )*
# hasher, ( a, a1 )* -[[hash_(arity:2)(0)]]-> hasher | a implements Hash, a1 has Hash, hasher implements Hasher
# hasher, ( a, a1 )* -[[hash_(arity:2)(0)]]-> hasher | a implements Hash, a1 has Hash, hasher implements Hasher
# hasher, ( a, a1 )* -[[hash_(arity:2)(0)]]-> hasher | a implements Hash, a1 implements Hash, hasher implements Hasher
# hasher, ( a, a1 )* -[[hash_(arity:2)(0)]]-> hasher | a implements Hash, a1 implements Hash, hasher implements Hasher
# Specialization lambda sets:
# @<1>: [[hash_(arity:2)(0)]]
#Derived.hash_(arity:2) =
@ -246,8 +246,8 @@ fn tag_one_label_newtype() {
derive_test(Hash, v!([A v!(U8) v!(STR)]), |golden| {
assert_snapshot!(golden, @r###"
# derived for [A U8 Str]
# hasher, [A a a1] -[[hash_[A 2](0)]]-> hasher | a implements Hash, a1 has Hash, hasher implements Hasher
# hasher, [A a a1] -[[hash_[A 2](0)]]-> hasher | a implements Hash, a1 has Hash, hasher implements Hasher
# hasher, [A a a1] -[[hash_[A 2](0)]]-> hasher | a implements Hash, a1 implements Hash, hasher implements Hasher
# hasher, [A a a1] -[[hash_[A 2](0)]]-> hasher | a implements Hash, a1 implements Hash, hasher implements Hasher
# Specialization lambda sets:
# @<1>: [[hash_[A 2](0)]]
#Derived.hash_[A 2] =
@ -263,8 +263,8 @@ fn tag_two_labels() {
derive_test(Hash, v!([A v!(U8) v!(STR) v!(U16), B v!(STR)]), |golden| {
assert_snapshot!(golden, @r###"
# derived for [A U8 Str U16, B Str]
# a, [A a1 a2 a3, B a3] -[[hash_[A 3,B 1](0)]]-> a | a implements Hasher, a1 has Hash, a2 has Hash, a3 implements Hash
# a, [A a1 a2 a3, B a3] -[[hash_[A 3,B 1](0)]]-> a | a implements Hasher, a1 has Hash, a2 has Hash, a3 implements Hash
# a, [A a1 a2 a3, B a3] -[[hash_[A 3,B 1](0)]]-> a | a implements Hasher, a1 implements Hash, a2 implements Hash, a3 implements Hash
# a, [A a1 a2 a3, B a3] -[[hash_[A 3,B 1](0)]]-> a | a implements Hasher, a1 implements Hash, a2 implements Hash, a3 implements Hash
# Specialization lambda sets:
# @<1>: [[hash_[A 3,B 1](0)]]
#Derived.hash_[A 3,B 1] =
@ -304,8 +304,8 @@ fn recursive_tag_union() {
derive_test(Hash, v!([Nil, Cons v!(U8) v!(^lst) ] as lst), |golden| {
assert_snapshot!(golden, @r###"
# derived for [Cons U8 $rec, Nil] as $rec
# a, [Cons a1 a2, Nil] -[[hash_[Cons 2,Nil 0](0)]]-> a | a implements Hasher, a1 has Hash, a2 implements Hash
# a, [Cons a1 a2, Nil] -[[hash_[Cons 2,Nil 0](0)]]-> a | a implements Hasher, a1 has Hash, a2 implements Hash
# a, [Cons a1 a2, Nil] -[[hash_[Cons 2,Nil 0](0)]]-> a | a implements Hasher, a1 implements Hash, a2 implements Hash
# a, [Cons a1 a2, Nil] -[[hash_[Cons 2,Nil 0](0)]]-> a | a implements Hasher, a1 implements Hash, a2 implements Hash
# Specialization lambda sets:
# @<1>: [[hash_[Cons 2,Nil 0](0)]]
#Derived.hash_[Cons 2,Nil 0] =

View File

@ -182,7 +182,7 @@ macro_rules! v {
use roc_types::subs::{Subs, Content};
|subs: &mut Subs| { roc_derive::synth_var(subs, Content::FlexVar(None)) }
}};
($name:ident has $ability:path) => {{
($name:ident implements $ability:path) => {{
use roc_types::subs::{Subs, SubsIndex, SubsSlice, Content};
|subs: &mut Subs| {
let name_index =

View File

@ -604,7 +604,7 @@ fn variable_to_string(
for (i, (var, abilities)) in ctx.able_variables.into_iter().enumerate() {
buf.push_str(if i == 0 { " | " } else { ", " });
buf.push_str(var);
buf.push_str(" has");
buf.push_str(" implements");
for (i, ability) in abilities.into_sorted_iter().enumerate() {
if i > 0 {
buf.push_str(" &");

View File

@ -4005,7 +4005,7 @@ fn write_debug_error_type_help(error_type: ErrorType, buf: &mut String, parens:
buf.push('(');
}
buf.push_str(name.as_str());
write!(buf, "has {:?}", symbol).unwrap();
write!(buf, "implements {:?}", symbol).unwrap();
if write_parens {
buf.push(')');
}