Simpl decoder a bit

This commit is contained in:
Ayaz Hafiz 2022-05-07 14:03:19 -04:00 committed by ayazhafiz
parent e08b5fa91e
commit 4a623a48dc
2 changed files with 27 additions and 6 deletions

View file

@ -5928,6 +5928,13 @@ pub fn from_can<'a>(
let _res =
roc_unify::unify::unify(env.subs, var, def.expr_var, Mode::EQ);
resolve_abilities_in_specialized_body(
env,
procs,
&def.loc_expr.value,
def.expr_var,
);
return with_hole(
env,
def.loc_expr.value,
@ -5959,6 +5966,13 @@ pub fn from_can<'a>(
Mode::EQ,
);
resolve_abilities_in_specialized_body(
env,
procs,
&def.loc_expr.value,
def.expr_var,
);
stmt = with_hole(
env,
specialized_expr,
@ -6017,6 +6031,13 @@ pub fn from_can<'a>(
let outer_symbol = env.unique_symbol();
stmt = store_pattern(env, procs, layout_cache, &mono_pattern, outer_symbol, stmt);
resolve_abilities_in_specialized_body(
env,
procs,
&def.loc_expr.value,
def.expr_var,
);
// convert the def body, store in outer_symbol
with_hole(
env,

View file

@ -292,9 +292,10 @@ fn decode() {
fromBytes = \lst, fmt ->
when decodeWith lst decoder fmt is
{ result, rest } ->
when result is
Ok val -> if List.isEmpty rest then Ok val else Err (Leftover rest)
Err e -> Err e
Result.after result \val ->
if List.isEmpty rest
then Ok val
else Err (Leftover rest)
Linear := {}
@ -309,9 +310,8 @@ fn decode() {
# impl Decoding for MyU8
decoder = @Decoder \lst, fmt ->
when decodeWith lst u8 fmt is
{ result, rest } ->
{ result: Result.map result (\n -> @MyU8 n), rest }
{ result, rest } = decodeWith lst u8 fmt
{ result: Result.map result (\n -> @MyU8 n), rest }
myU8 =
when fromBytes [ 15 ] (@Linear {}) is