mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
abilities syntax has
-> implements
This commit is contained in:
parent
91e37293a2
commit
dbc0204532
21 changed files with 89 additions and 84 deletions
|
@ -63,7 +63,7 @@ fn wrap_in_decode_custom_decode_with(
|
|||
|
||||
// Decode.decodeWith bytes inner_decoder fmt : DecodeResult val
|
||||
let (decode_with_call, decode_with_result_var) = {
|
||||
// Decode.decodeWith : List U8, Decoder val fmt, fmt -> DecodeResult val | fmt has DecoderFormatting
|
||||
// Decode.decodeWith : List U8, Decoder val fmt, fmt -> DecodeResult val | fmt implements DecoderFormatting
|
||||
let decode_with_type = env.import_builtin_symbol_var(Symbol::DECODE_DECODE_WITH);
|
||||
|
||||
// Decode.decodeWith : bytes, inner_decoder, fmt -> DecoderResult (List val)
|
||||
|
@ -80,7 +80,7 @@ fn wrap_in_decode_custom_decode_with(
|
|||
)),
|
||||
);
|
||||
|
||||
// List U8, Decoder val fmt, fmt -> DecodeResult val | fmt has DecoderFormatting
|
||||
// List U8, Decoder val fmt, fmt -> DecodeResult val | fmt implements DecoderFormatting
|
||||
// ~ bytes, Decoder (List elem) fmt, fmt -> DecoderResult (List val)
|
||||
env.unify(decode_with_type, this_decode_with_fn_var);
|
||||
|
||||
|
@ -169,7 +169,7 @@ fn wrap_in_decode_custom_decode_with(
|
|||
|
||||
// Decode.custom \bytes, fmt -> Decode.decodeWith bytes inner_decoder fmt
|
||||
let (decode_custom_call, decoder_var) = {
|
||||
// (List U8, fmt -> DecodeResult val) -> Decoder val fmt | fmt has DecoderFormatting
|
||||
// (List U8, fmt -> DecodeResult val) -> Decoder val fmt | fmt implements DecoderFormatting
|
||||
let decode_custom_type = env.import_builtin_symbol_var(Symbol::DECODE_CUSTOM);
|
||||
|
||||
// (List U8, fmt -> DecodeResult (List elem)) -> Decoder (List elem) fmt
|
||||
|
@ -185,7 +185,7 @@ fn wrap_in_decode_custom_decode_with(
|
|||
)),
|
||||
);
|
||||
|
||||
// (List U8, fmt -> DecodeResult val) -> Decoder val fmt | fmt has DecoderFormatting
|
||||
// (List U8, fmt -> DecodeResult val) -> Decoder val fmt | fmt implements DecoderFormatting
|
||||
// ~ (List U8, fmt -> DecodeResult (List elem)) -> Decoder (List elem) fmt
|
||||
env.unify(decode_custom_type, this_decode_custom_fn_var);
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ use crate::util::Env;
|
|||
pub(crate) fn decoder(env: &mut Env<'_>, _def_symbol: Symbol) -> (Expr, Variable) {
|
||||
// Build
|
||||
//
|
||||
// def_symbol : Decoder (List elem) fmt | elem has Decoding, fmt has DecoderFormatting
|
||||
// def_symbol : Decoder (List elem) fmt | elem has Decoding, fmt implements DecoderFormatting
|
||||
// def_symbol = Decode.custom \bytes, fmt -> Decode.decodeWith bytes (Decode.list Decode.decoder) fmt
|
||||
//
|
||||
// NB: reduction to `Decode.list Decode.decoder` is not possible to the HRR.
|
||||
|
@ -27,10 +27,10 @@ pub(crate) fn decoder(env: &mut Env<'_>, _def_symbol: Symbol) -> (Expr, Variable
|
|||
// List elem
|
||||
let elem_var = env.subs.fresh_unnamed_flex_var();
|
||||
|
||||
// Decode.decoder : Decoder elem fmt | elem has Decoding, fmt has EncoderFormatting
|
||||
// Decode.decoder : Decoder elem fmt | elem has Decoding, fmt implements EncoderFormatting
|
||||
let (elem_decoder, elem_decoder_var) = {
|
||||
// build `Decode.decoder : Decoder elem fmt` type
|
||||
// Decoder val fmt | val has Decoding, fmt has EncoderFormatting
|
||||
// Decoder val fmt | val has Decoding, fmt implements EncoderFormatting
|
||||
let elem_decoder_var = env.import_builtin_symbol_var(Symbol::DECODE_DECODER);
|
||||
|
||||
// set val ~ elem
|
||||
|
@ -52,7 +52,7 @@ pub(crate) fn decoder(env: &mut Env<'_>, _def_symbol: Symbol) -> (Expr, Variable
|
|||
};
|
||||
|
||||
// Build `Decode.list Decode.decoder` type
|
||||
// Decoder val fmt -[uls]-> Decoder (List val) fmt | fmt has DecoderFormatting
|
||||
// Decoder val fmt -[uls]-> Decoder (List val) fmt | fmt implements DecoderFormatting
|
||||
let decode_list_fn_var = env.import_builtin_symbol_var(Symbol::DECODE_LIST);
|
||||
|
||||
// Decoder elem fmt -a-> b
|
||||
|
@ -68,7 +68,7 @@ pub(crate) fn decoder(env: &mut Env<'_>, _def_symbol: Symbol) -> (Expr, Variable
|
|||
)),
|
||||
);
|
||||
|
||||
// Decoder val fmt -[uls]-> Decoder (List val) fmt | fmt has DecoderFormatting
|
||||
// Decoder val fmt -[uls]-> Decoder (List val) fmt | fmt implements DecoderFormatting
|
||||
// ~ Decoder elem fmt -a -> b
|
||||
env.unify(decode_list_fn_var, this_decode_list_fn_var);
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ use super::wrap_in_decode_custom_decode_with;
|
|||
/// we'd like to generate an impl like
|
||||
///
|
||||
/// ```roc
|
||||
/// decoder : Decoder {first: a, second: b} fmt | a has Decoding, b has Decoding, fmt has DecoderFormatting
|
||||
/// decoder : Decoder {first: a, second: b} fmt | a implements Decoding, b implements Decoding, fmt implements DecoderFormatting
|
||||
/// decoder =
|
||||
/// initialState : {f0: Result a [NoField], f1: Result b [NoField]}
|
||||
/// initialState = {f0: Err NoField, f1: Err NoField}
|
||||
|
|
|
@ -28,7 +28,7 @@ use super::wrap_in_decode_custom_decode_with;
|
|||
/// we'd like to generate an impl like
|
||||
///
|
||||
/// ```roc
|
||||
/// decoder : Decoder (a, b) fmt | a has Decoding, b has Decoding, fmt has DecoderFormatting
|
||||
/// decoder : Decoder (a, b) fmt | a implements Decoding, b implements Decoding, fmt implements DecoderFormatting
|
||||
/// decoder =
|
||||
/// initialState : {e0: Result a [NoElem], e1: Result b [NoElem]}
|
||||
/// initialState = {e0: Err NoElem, e1: Err NoElem}
|
||||
|
|
|
@ -121,7 +121,7 @@ fn to_encoder_list(env: &mut Env<'_>, fn_name: Symbol) -> (Expr, Variable) {
|
|||
);
|
||||
|
||||
// build `toEncoder elem` type
|
||||
// val -[uls]-> Encoder fmt | fmt has EncoderFormatting
|
||||
// val -[uls]-> Encoder fmt | fmt implements EncoderFormatting
|
||||
let to_encoder_fn_var = env.import_builtin_symbol_var(Symbol::ENCODE_TO_ENCODER);
|
||||
|
||||
// elem -[clos]-> t1
|
||||
|
@ -136,11 +136,11 @@ fn to_encoder_list(env: &mut Env<'_>, fn_name: Symbol) -> (Expr, Variable) {
|
|||
)),
|
||||
);
|
||||
|
||||
// val -[uls]-> Encoder fmt | fmt has EncoderFormatting
|
||||
// val -[uls]-> Encoder fmt | fmt implements EncoderFormatting
|
||||
// ~ elem -[clos]-> t1
|
||||
env.unify(to_encoder_fn_var, elem_to_encoder_fn_var);
|
||||
|
||||
// toEncoder : (typeof rcd.a) -[clos]-> Encoder fmt | fmt has EncoderFormatting
|
||||
// toEncoder : (typeof rcd.a) -[clos]-> Encoder fmt | fmt implements EncoderFormatting
|
||||
let to_encoder_var = AbilityMember(Symbol::ENCODE_TO_ENCODER, None, elem_to_encoder_fn_var);
|
||||
let to_encoder_fn = Box::new((
|
||||
to_encoder_fn_var,
|
||||
|
@ -201,7 +201,7 @@ fn to_encoder_list(env: &mut Env<'_>, fn_name: Symbol) -> (Expr, Variable) {
|
|||
});
|
||||
|
||||
// build `Encode.list lst (\elem -> Encode.toEncoder elem)` type
|
||||
// List e, (e -> Encoder fmt) -[uls]-> Encoder fmt | fmt has EncoderFormatting
|
||||
// List e, (e -> Encoder fmt) -[uls]-> Encoder fmt | fmt implements EncoderFormatting
|
||||
let encode_list_fn_var = env.import_builtin_symbol_var(Symbol::ENCODE_LIST);
|
||||
|
||||
// List elem, to_elem_encoder_fn_var -[clos]-> t1
|
||||
|
@ -218,11 +218,11 @@ fn to_encoder_list(env: &mut Env<'_>, fn_name: Symbol) -> (Expr, Variable) {
|
|||
)),
|
||||
);
|
||||
|
||||
// List e, (e -> Encoder fmt) -[uls]-> Encoder fmt | fmt has EncoderFormatting
|
||||
// List e, (e -> Encoder fmt) -[uls]-> Encoder fmt | fmt implements EncoderFormatting
|
||||
// ~ List elem, to_elem_encoder_fn_var -[clos]-> t1
|
||||
env.unify(encode_list_fn_var, this_encode_list_fn_var);
|
||||
|
||||
// Encode.list : List elem, to_elem_encoder_fn_var -[clos]-> Encoder fmt | fmt has EncoderFormatting
|
||||
// Encode.list : List elem, to_elem_encoder_fn_var -[clos]-> Encoder fmt | fmt implements EncoderFormatting
|
||||
let encode_list = AbilityMember(Symbol::ENCODE_LIST, None, this_encode_list_fn_var);
|
||||
let encode_list_fn = Box::new((
|
||||
this_encode_list_fn_var,
|
||||
|
@ -340,7 +340,7 @@ fn to_encoder_record(
|
|||
};
|
||||
|
||||
// build `toEncoder rcd.a` type
|
||||
// val -[uls]-> Encoder fmt | fmt has EncoderFormatting
|
||||
// val -[uls]-> Encoder fmt | fmt implements EncoderFormatting
|
||||
let to_encoder_fn_var = env.import_builtin_symbol_var(Symbol::ENCODE_TO_ENCODER);
|
||||
|
||||
// (typeof rcd.a) -[clos]-> t1
|
||||
|
@ -355,11 +355,11 @@ fn to_encoder_record(
|
|||
)),
|
||||
);
|
||||
|
||||
// val -[uls]-> Encoder fmt | fmt has EncoderFormatting
|
||||
// val -[uls]-> Encoder fmt | fmt implements EncoderFormatting
|
||||
// ~ (typeof rcd.a) -[clos]-> t1
|
||||
env.unify(to_encoder_fn_var, this_to_encoder_fn_var);
|
||||
|
||||
// toEncoder : (typeof rcd.a) -[clos]-> Encoder fmt | fmt has EncoderFormatting
|
||||
// toEncoder : (typeof rcd.a) -[clos]-> Encoder fmt | fmt implements EncoderFormatting
|
||||
let to_encoder_var = AbilityMember(Symbol::ENCODE_TO_ENCODER, None, to_encoder_fn_var);
|
||||
let to_encoder_fn = Box::new((
|
||||
to_encoder_fn_var,
|
||||
|
@ -420,7 +420,7 @@ fn to_encoder_record(
|
|||
};
|
||||
|
||||
// build `Encode.record [ { key: .., value: ..}, .. ]` type
|
||||
// List { key : Str, value : Encoder fmt } -[uls]-> Encoder fmt | fmt has EncoderFormatting
|
||||
// List { key : Str, value : Encoder fmt } -[uls]-> Encoder fmt | fmt implements EncoderFormatting
|
||||
let encode_record_fn_var = env.import_builtin_symbol_var(Symbol::ENCODE_RECORD);
|
||||
|
||||
// fields_list_var -[clos]-> t1
|
||||
|
@ -437,11 +437,11 @@ fn to_encoder_record(
|
|||
)),
|
||||
);
|
||||
|
||||
// List { key : Str, value : Encoder fmt } -[uls]-> Encoder fmt | fmt has EncoderFormatting
|
||||
// List { key : Str, value : Encoder fmt } -[uls]-> Encoder fmt | fmt implements EncoderFormatting
|
||||
// ~ fields_list_var -[clos]-> t1
|
||||
env.unify(encode_record_fn_var, this_encode_record_fn_var);
|
||||
|
||||
// Encode.record : fields_list_var -[clos]-> Encoder fmt | fmt has EncoderFormatting
|
||||
// Encode.record : fields_list_var -[clos]-> Encoder fmt | fmt implements EncoderFormatting
|
||||
let encode_record_var = AbilityMember(Symbol::ENCODE_RECORD, None, encode_record_fn_var);
|
||||
let encode_record_fn = Box::new((
|
||||
encode_record_fn_var,
|
||||
|
@ -543,7 +543,7 @@ fn to_encoder_tuple(
|
|||
};
|
||||
|
||||
// build `toEncoder tup.0` type
|
||||
// val -[uls]-> Encoder fmt | fmt has EncoderFormatting
|
||||
// val -[uls]-> Encoder fmt | fmt implements EncoderFormatting
|
||||
let to_encoder_fn_var = env.import_builtin_symbol_var(Symbol::ENCODE_TO_ENCODER);
|
||||
|
||||
// (typeof tup.0) -[clos]-> t1
|
||||
|
@ -558,11 +558,11 @@ fn to_encoder_tuple(
|
|||
)),
|
||||
);
|
||||
|
||||
// val -[uls]-> Encoder fmt | fmt has EncoderFormatting
|
||||
// val -[uls]-> Encoder fmt | fmt implements EncoderFormatting
|
||||
// ~ (typeof tup.0) -[clos]-> t1
|
||||
env.unify(to_encoder_fn_var, this_to_encoder_fn_var);
|
||||
|
||||
// toEncoder : (typeof tup.0) -[clos]-> Encoder fmt | fmt has EncoderFormatting
|
||||
// toEncoder : (typeof tup.0) -[clos]-> Encoder fmt | fmt implements EncoderFormatting
|
||||
let to_encoder_var = AbilityMember(Symbol::ENCODE_TO_ENCODER, None, to_encoder_fn_var);
|
||||
let to_encoder_fn = Box::new((
|
||||
to_encoder_fn_var,
|
||||
|
@ -603,7 +603,7 @@ fn to_encoder_tuple(
|
|||
};
|
||||
|
||||
// build `Encode.tuple [ toEncoder tup.0, toEncoder tup.1 ]` type
|
||||
// List (Encoder fmt) -[uls]-> Encoder fmt | fmt has EncoderFormatting
|
||||
// List (Encoder fmt) -[uls]-> Encoder fmt | fmt implements EncoderFormatting
|
||||
let encode_tuple_fn_var = env.import_builtin_symbol_var(Symbol::ENCODE_TUPLE);
|
||||
|
||||
// elem_encoders_list_var -[clos]-> t1
|
||||
|
@ -620,11 +620,11 @@ fn to_encoder_tuple(
|
|||
)),
|
||||
);
|
||||
|
||||
// List (Encoder fmt) -[uls]-> Encoder fmt | fmt has EncoderFormatting
|
||||
// List (Encoder fmt) -[uls]-> Encoder fmt | fmt implements EncoderFormatting
|
||||
// ~ elem_encoders_list_var -[clos]-> t1
|
||||
env.unify(encode_tuple_fn_var, this_encode_tuple_fn_var);
|
||||
|
||||
// Encode.tuple : elem_encoders_list_var -[clos]-> Encoder fmt | fmt has EncoderFormatting
|
||||
// Encode.tuple : elem_encoders_list_var -[clos]-> Encoder fmt | fmt implements EncoderFormatting
|
||||
let encode_tuple_var = AbilityMember(Symbol::ENCODE_TUPLE, None, encode_tuple_fn_var);
|
||||
let encode_tuple_fn = Box::new((
|
||||
encode_tuple_fn_var,
|
||||
|
@ -741,7 +741,7 @@ fn to_encoder_tag_union(
|
|||
.zip(payload_vars.iter())
|
||||
.map(|(&sym, &sym_var)| {
|
||||
// build `toEncoder v1` type
|
||||
// expected: val -[uls]-> Encoder fmt | fmt has EncoderFormatting
|
||||
// expected: val -[uls]-> Encoder fmt | fmt implements EncoderFormatting
|
||||
let to_encoder_fn_var =
|
||||
env.import_builtin_symbol_var(Symbol::ENCODE_TO_ENCODER);
|
||||
|
||||
|
@ -759,11 +759,11 @@ fn to_encoder_tag_union(
|
|||
)),
|
||||
);
|
||||
|
||||
// val -[uls]-> Encoder fmt | fmt has EncoderFormatting
|
||||
// val -[uls]-> Encoder fmt | fmt implements EncoderFormatting
|
||||
// ~ t1 -[clos]-> t'
|
||||
env.unify(to_encoder_fn_var, this_to_encoder_fn_var);
|
||||
|
||||
// toEncoder : t1 -[clos]-> Encoder fmt | fmt has EncoderFormatting
|
||||
// toEncoder : t1 -[clos]-> Encoder fmt | fmt implements EncoderFormatting
|
||||
let to_encoder_var =
|
||||
AbilityMember(Symbol::ENCODE_TO_ENCODER, None, this_to_encoder_fn_var);
|
||||
let to_encoder_fn = Box::new((
|
||||
|
@ -802,7 +802,7 @@ fn to_encoder_tag_union(
|
|||
};
|
||||
|
||||
// build `Encode.tag "A" [ ... ]` type
|
||||
// expected: Str, List (Encoder fmt) -[uls]-> Encoder fmt | fmt has EncoderFormatting
|
||||
// expected: Str, List (Encoder fmt) -[uls]-> Encoder fmt | fmt implements EncoderFormatting
|
||||
let encode_tag_fn_var = env.import_builtin_symbol_var(Symbol::ENCODE_TAG);
|
||||
|
||||
// wanted: Str, List whole_encoders_var -[clos]-> t'
|
||||
|
@ -821,11 +821,11 @@ fn to_encoder_tag_union(
|
|||
)),
|
||||
);
|
||||
|
||||
// Str, List (Encoder fmt) -[uls]-> Encoder fmt | fmt has EncoderFormatting
|
||||
// Str, List (Encoder fmt) -[uls]-> Encoder fmt | fmt implements EncoderFormatting
|
||||
// ~ Str, List whole_encoders_var -[clos]-> t'
|
||||
env.unify(encode_tag_fn_var, this_encode_tag_fn_var);
|
||||
|
||||
// Encode.tag : Str, List whole_encoders_var -[clos]-> Encoder fmt | fmt has EncoderFormatting
|
||||
// Encode.tag : Str, List whole_encoders_var -[clos]-> Encoder fmt | fmt implements EncoderFormatting
|
||||
let encode_tag_var = AbilityMember(Symbol::ENCODE_TAG, None, this_encode_tag_fn_var);
|
||||
let encode_tag_fn = Box::new((
|
||||
this_encode_tag_fn_var,
|
||||
|
@ -954,15 +954,15 @@ fn wrap_in_encode_custom(
|
|||
let bytes_sym = env.new_symbol("bytes");
|
||||
let bytes_var = Variable::LIST_U8;
|
||||
|
||||
// fmt: fmt | fmt has EncoderFormatting
|
||||
// fmt: fmt | fmt implements EncoderFormatting
|
||||
let fmt_sym = env.new_symbol("fmt");
|
||||
let fmt_var = env.subs.fresh_unnamed_flex_var();
|
||||
|
||||
// build `Encode.appendWith bytes encoder fmt` type
|
||||
// expected: Encode.appendWith : List U8, Encoder fmt, fmt -[appendWith]-> List U8 | fmt has EncoderFormatting
|
||||
// expected: Encode.appendWith : List U8, Encoder fmt, fmt -[appendWith]-> List U8 | fmt implements EncoderFormatting
|
||||
let append_with_fn_var = env.import_builtin_symbol_var(Symbol::ENCODE_APPEND_WITH);
|
||||
|
||||
// wanted: Encode.appendWith : List U8, encoder_var, fmt -[clos]-> List U8 | fmt has EncoderFormatting
|
||||
// wanted: Encode.appendWith : List U8, encoder_var, fmt -[clos]-> List U8 | fmt implements EncoderFormatting
|
||||
let this_append_with_args_var_slice =
|
||||
VariableSubsSlice::insert_into_subs(env.subs, [Variable::LIST_U8, encoder_var, fmt_var]);
|
||||
let this_append_with_clos_var = env.subs.fresh_unnamed_flex_var(); // -[clos]->
|
||||
|
@ -975,11 +975,11 @@ fn wrap_in_encode_custom(
|
|||
)),
|
||||
);
|
||||
|
||||
// List U8, Encoder fmt, fmt -[appendWith]-> List U8 | fmt has EncoderFormatting
|
||||
// ~ List U8, encoder_var, fmt -[clos]-> List U8 | fmt has EncoderFormatting
|
||||
// List U8, Encoder fmt, fmt -[appendWith]-> List U8 | fmt implements EncoderFormatting
|
||||
// ~ List U8, encoder_var, fmt -[clos]-> List U8 | fmt implements EncoderFormatting
|
||||
env.unify(append_with_fn_var, this_append_with_fn_var);
|
||||
|
||||
// Encode.appendWith : List U8, encoder_var, fmt -[appendWith]-> List U8 | fmt has EncoderFormatting
|
||||
// Encode.appendWith : List U8, encoder_var, fmt -[appendWith]-> List U8 | fmt implements EncoderFormatting
|
||||
let append_with_fn = Box::new((
|
||||
this_append_with_fn_var,
|
||||
Loc::at_zero(Var(Symbol::ENCODE_APPEND_WITH, this_append_with_fn_var)),
|
||||
|
@ -1050,7 +1050,7 @@ fn wrap_in_encode_custom(
|
|||
// Build
|
||||
// Encode.custom \bytes, fmt -> Encode.appendWith bytes encoder fmt
|
||||
//
|
||||
// expected: Encode.custom : (List U8, fmt -> List U8) -> Encoder fmt | fmt has EncoderFormatting
|
||||
// expected: Encode.custom : (List U8, fmt -> List U8) -> Encoder fmt | fmt implements EncoderFormatting
|
||||
let custom_fn_var = env.import_builtin_symbol_var(Symbol::ENCODE_CUSTOM);
|
||||
|
||||
// wanted: Encode.custom : fn_var -[clos]-> t'
|
||||
|
@ -1066,11 +1066,11 @@ fn wrap_in_encode_custom(
|
|||
)),
|
||||
);
|
||||
|
||||
// (List U8, fmt -> List U8) -[..]-> Encoder fmt | fmt has EncoderFormatting
|
||||
// (List U8, fmt -> List U8) -[..]-> Encoder fmt | fmt implements EncoderFormatting
|
||||
// ~ fn_var -[clos]-> t'
|
||||
env.unify(custom_fn_var, this_custom_fn_var);
|
||||
|
||||
// Encode.custom : (List U8, fmt -> List U8) -> Encoder fmt | fmt has EncoderFormatting
|
||||
// Encode.custom : (List U8, fmt -> List U8) -> Encoder fmt | fmt implements EncoderFormatting
|
||||
let custom_fn = Box::new((
|
||||
this_custom_fn_var,
|
||||
Loc::at_zero(Var(Symbol::ENCODE_CUSTOM, this_custom_fn_var)),
|
||||
|
|
|
@ -75,7 +75,7 @@ fn hash_record(env: &mut Env<'_>, fn_name: Symbol, fields: Vec<Lowercase>) -> (V
|
|||
|
||||
// Now, a hasher for this record is
|
||||
//
|
||||
// hash_rcd : hasher, { f1: t1, ..., fn: tn } -> hasher | hasher has Hasher
|
||||
// hash_rcd : hasher, { f1: t1, ..., fn: tn } -> hasher | hasher implements Hasher
|
||||
// hash_rcd = \hasher, rcd ->
|
||||
// Hash.hash (
|
||||
// Hash.hash
|
||||
|
@ -144,7 +144,7 @@ fn hash_tuple(env: &mut Env<'_>, fn_name: Symbol, arity: u32) -> (Variable, Expr
|
|||
|
||||
// Now, a hasher for this tuple is
|
||||
//
|
||||
// hash_tup : hasher, (t1, ..., tn) -> hasher | hasher has Hasher
|
||||
// hash_tup : hasher, (t1, ..., tn) -> hasher | hasher implements Hasher
|
||||
// hash_tup = \hasher, tup ->
|
||||
// Hash.hash (
|
||||
// Hash.hash
|
||||
|
@ -227,7 +227,7 @@ fn hash_tag_union(
|
|||
|
||||
// Now, a hasher for this tag union is
|
||||
//
|
||||
// hash_union : hasher, [ A t11 .. t1n, ..., Q tq1 .. tqm ] -> hasher | hasher has Hasher
|
||||
// hash_union : hasher, [ A t11 .. t1n, ..., Q tq1 .. tqm ] -> hasher | hasher implements Hasher
|
||||
// hash_union = \hasher, union ->
|
||||
// when union is
|
||||
// A x11 .. x1n -> Hash.hash (... (Hash.hash (Hash.uN hasher 0) x11) ...) x1n
|
||||
|
@ -393,7 +393,7 @@ fn hash_newtype_tag_union(
|
|||
|
||||
// Now, a hasher for this tag union is
|
||||
//
|
||||
// hash_union : hasher, [ A t1 .. tn ] -> hasher | hasher has Hasher
|
||||
// hash_union : hasher, [ A t1 .. tn ] -> hasher | hasher implements Hasher
|
||||
// hash_union = \hasher, A x1 .. xn ->
|
||||
// Hash.hash (... (Hash.hash discrHasher x1) ...) xn
|
||||
let hasher_sym = env.new_symbol("hasher");
|
||||
|
@ -462,7 +462,7 @@ fn call_hash_ability_member(
|
|||
|
||||
// build `member ...` function type. `member` here is `Hash.hash` or `Hash.addU16`.
|
||||
//
|
||||
// hasher, val -[uls]-> hasher | hasher has Hasher, val has Hash
|
||||
// hasher, val -[uls]-> hasher | hasher has Hasher, val implements Hash
|
||||
let exposed_hash_fn_var = env.import_builtin_symbol_var(member);
|
||||
|
||||
// (typeof body), (typeof field) -[clos]-> hasher_result
|
||||
|
@ -479,11 +479,11 @@ fn call_hash_ability_member(
|
|||
)),
|
||||
);
|
||||
|
||||
// hasher, val -[uls]-> hasher | hasher has Hasher, val has Hash
|
||||
// hasher, val -[uls]-> hasher | hasher has Hasher, val implements Hash
|
||||
// ~ (typeof body), (typeof field) -[clos]-> hasher_result
|
||||
env.unify(exposed_hash_fn_var, this_hash_fn_var);
|
||||
|
||||
// Hash.hash : hasher, (typeof field) -[clos]-> hasher | hasher has Hasher, (typeof field) has Hash
|
||||
// Hash.hash : hasher, (typeof field) -[clos]-> hasher | hasher has Hasher, (typeof field) implements Hash
|
||||
let hash_fn_head = Expr::AbilityMember(member, None, this_hash_fn_var);
|
||||
let hash_fn_data = Box::new((
|
||||
this_hash_fn_var,
|
||||
|
|
|
@ -130,7 +130,7 @@ impl Env<'_> {
|
|||
})
|
||||
.collect();
|
||||
|
||||
// Since we're doing `{foo} ~ a | a has Encoding`, we may see "lambda sets to
|
||||
// Since we're doing `{foo} ~ a | a implements Encoding`, we may see "lambda sets to
|
||||
// specialize" for e.g. `{foo}:toEncoder:1`, but these are actually just the
|
||||
// specialization lambda sets, so we don't need to do any extra work!
|
||||
//
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue