mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 08:11:12 +00:00
Simpl decoder a bit
This commit is contained in:
parent
e08b5fa91e
commit
4a623a48dc
2 changed files with 27 additions and 6 deletions
|
@ -5928,6 +5928,13 @@ pub fn from_can<'a>(
|
||||||
let _res =
|
let _res =
|
||||||
roc_unify::unify::unify(env.subs, var, def.expr_var, Mode::EQ);
|
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(
|
return with_hole(
|
||||||
env,
|
env,
|
||||||
def.loc_expr.value,
|
def.loc_expr.value,
|
||||||
|
@ -5959,6 +5966,13 @@ pub fn from_can<'a>(
|
||||||
Mode::EQ,
|
Mode::EQ,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
resolve_abilities_in_specialized_body(
|
||||||
|
env,
|
||||||
|
procs,
|
||||||
|
&def.loc_expr.value,
|
||||||
|
def.expr_var,
|
||||||
|
);
|
||||||
|
|
||||||
stmt = with_hole(
|
stmt = with_hole(
|
||||||
env,
|
env,
|
||||||
specialized_expr,
|
specialized_expr,
|
||||||
|
@ -6017,6 +6031,13 @@ pub fn from_can<'a>(
|
||||||
let outer_symbol = env.unique_symbol();
|
let outer_symbol = env.unique_symbol();
|
||||||
stmt = store_pattern(env, procs, layout_cache, &mono_pattern, outer_symbol, stmt);
|
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
|
// convert the def body, store in outer_symbol
|
||||||
with_hole(
|
with_hole(
|
||||||
env,
|
env,
|
||||||
|
|
|
@ -292,9 +292,10 @@ fn decode() {
|
||||||
fromBytes = \lst, fmt ->
|
fromBytes = \lst, fmt ->
|
||||||
when decodeWith lst decoder fmt is
|
when decodeWith lst decoder fmt is
|
||||||
{ result, rest } ->
|
{ result, rest } ->
|
||||||
when result is
|
Result.after result \val ->
|
||||||
Ok val -> if List.isEmpty rest then Ok val else Err (Leftover rest)
|
if List.isEmpty rest
|
||||||
Err e -> Err e
|
then Ok val
|
||||||
|
else Err (Leftover rest)
|
||||||
|
|
||||||
|
|
||||||
Linear := {}
|
Linear := {}
|
||||||
|
@ -309,8 +310,7 @@ fn decode() {
|
||||||
|
|
||||||
# impl Decoding for MyU8
|
# impl Decoding for MyU8
|
||||||
decoder = @Decoder \lst, fmt ->
|
decoder = @Decoder \lst, fmt ->
|
||||||
when decodeWith lst u8 fmt is
|
{ result, rest } = decodeWith lst u8 fmt
|
||||||
{ result, rest } ->
|
|
||||||
{ result: Result.map result (\n -> @MyU8 n), rest }
|
{ result: Result.map result (\n -> @MyU8 n), rest }
|
||||||
|
|
||||||
myU8 =
|
myU8 =
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue