Isn't it possible to do {a, b} as full_record
in the function arguments as is it is in when-is
?
This definition fails:
add_user : Database, { name : Str, owes ?? Dict Str Dec, owed_by ?? Dict Str Dec, balance ?? Dec} -> Result Database _
add_user = |database, { name, owes ?? Dict.empty({}), owed_by ?? Dict.empty({}), balance ?? 0.0} as user|
with error:
── MALFORMED ARGS LIST in ./Database.roc ───────────────────────────────────────
I was trying to parse the arguments list for a function, but I got
stuck here:
19│ add_user = |database, { name, owes ?? Dict.empty({}), owed_by ?? Dict.empty({}), balance ?? 0.0} as user|
^
I was expecting to find a | next.%
Not yet supported, but seems reasonable to add. Do you expect any problems from this @Anthony Bullard, @Joshua Warner?
That should be fine so long as the left side of the x as y
is an exhaustive pattern. I believe this has been already implemented in the way that @Ilya Shmygol wrote it in the new compiler's parsing code, but I might be wrong
Yeah, I think it just doesn't work with ??
But not fully sure
I honestly can’t remember if this will in fact “just work” in the new parser but I think so. I wish I had time to look at it right now
Brendan is probably right, but for those who don't know, ?? is going away in the rewrite
That’s news to me and the parser :joy:
wait, me too! :laughing:
unless I'm misremembering?
Optional/default value record fields are going away
I think ??
is switching to be Result.with_default(...)
At least that is what I remember being decided
But not fully sure on with default.
That’s somewhat sad, since it was implemented not even six months ago (by me) and has just as much value in a static dispatch world as before. And with_default has been there and will remain for when you want to chain it (we almost had ?? Desugar to it, but chose to use a when instead)
I liked ??
...
yeah I don't remember that change haha
in my mind, the plan was still to have ??
work the same as today
can anyone find a thread where we discussed changing that?
It may have stemmed from this discussion?
Brendan Hansknecht said:
Now that we have static dispatch do we expect to see issues with
?
and??
?
They no longer play nice with pipelinesout = (((load_config(in_file) ?? default_config) .stage1(abc) ? Stage1Err) .stage2() ? Stage2Err) .stage3() ? Stage3Err
To clarify my statement. In the new compiler, I would expect this to still just work:
out =
(((load_config(in_file) ?? default_config)
.stage1(abc) ? Stage1Err)
.stage2() ? Stage2Err)
.stage3() ? Stage3Err
I just recall a discussion on default value record fields like:
fn = |record : {x ?? i32, y ?? i32}|
{x ?? 0, y ?? 0} = record
x + y
In that discussion, richard suggested we should remove them cause overall they had been confusing and error prone for users.
I think this is the most official message of removal, but significant discussion definitely happened in idea threads much earlier:
Richard Feldman said:
of note, the "demanded" enum for records isn't necessary anymore due to optional record fields going away
ohh yeah, I misunderstood
so my understanding is that:
??
is still an infix operator, which works the same way as today??
as their syntax for specifying the default fields yeah, exactly that.
yep!
Sweet, that makes sense
Last updated: Jul 06 2025 at 12:14 UTC