mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 13:59:08 +00:00
|
-> where
This commit is contained in:
parent
fd846b9a7a
commit
cb08225bf0
117 changed files with 637 additions and 612 deletions
|
@ -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 implements Decoding, fmt implements DecoderFormatting
|
||||
// def_symbol : Decoder (List elem) fmt where elem implements 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 implements Decoding, fmt implements EncoderFormatting
|
||||
// Decode.decoder : Decoder elem fmt where elem implements Decoding, fmt implements EncoderFormatting
|
||||
let (elem_decoder, elem_decoder_var) = {
|
||||
// build `Decode.decoder : Decoder elem fmt` type
|
||||
// Decoder val fmt | val implements Decoding, fmt implements EncoderFormatting
|
||||
// Decoder val fmt where val implements 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 implements DecoderFormatting
|
||||
// Decoder val fmt -[uls]-> Decoder (List val) fmt where 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 implements DecoderFormatting
|
||||
// Decoder val fmt -[uls]-> Decoder (List val) fmt where 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 implements Decoding, b implements Decoding, fmt implements DecoderFormatting
|
||||
/// decoder : Decoder {first: a, second: b} fmt where 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 implements Decoding, b implements Decoding, fmt implements DecoderFormatting
|
||||
/// decoder : Decoder (a, b) fmt where 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}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue