Just want to double check, this should work eventually, right?
main =
Arg.list! {}
|> List.dropFirst 1
|> List.mapTry Str.toU8
|> Task.fromResult!
|> List.sum
|> \total -> "Sum of numbers: $(Num.toStr total)"
|> Stdout.line!
Or do we not plan to allow !
in pipes? I would assume it should be allowed.
It's discussed in the Proposal: Chaining Syntax in section Pipelines.
I would expect what you have written to desguar to effectively the following (simplified)
main =
Arg.list! {}
|> List.dropFirst 1
|> List.mapTry Str.toU8Checked
|> Task.fromResult!
|> List.sum
|> \total -> "Sum of numbers: $(Num.toStr total)"
|> Stdout.line!
main =
Task.await (Arg.list {}) \answer1 ->
Task.await
(
answer1
|> List.dropFirst 1
|> List.mapTry Str.toU8Checked
|> Task.fromResult
)
\answer2 ->
answer2
|> List.sum
|> \total -> "Sum of numbers: $(Num.toStr total)"
|> Stdout.line
Makes sense. Not sure what is missing today, but I guess it is a reasonable bug case.
relatively minimal
It should work today
I'll make an issue while I have it open
https://github.com/roc-lang/basic-cli/issues/234
I’ll take a look today
Also, it can be cut to be a bit more minimal:
main =
Arg.list! {}
|> List.len
|> Num.toStr
|> Stdout.line!
Ah, have you tried to change the indentation?
Add one space to each pipe, does it help?
yeah, this works:
main =
Arg.list! {}
|> List.len
|> Num.toStr
|> Stdout.line!
So !
requires extra tabbing currently...interesting.
With the more nested version, it is still broken:
main =
Arg.list! {}
|> List.dropFirst 1
|> List.mapTry Str.toU8
|> Task.fromResult!
|> List.sum
|> \total -> "Sum of numbers: $(Num.toStr total)"
|> Stdout.line!
Yeah, it’s a known bug in parser. I assume it will go away with @Joshua Warner refactoring, but will give it another look today anyway
I just tested with the block changes -- it's still there
I'm not so sure it's a bug. I think it's a deliberate design choice/tradeoff we made.
Might be worth coming up with ideas to improve the experience here.
But could be tricky if it doesnt even parse I guess.
But the suffix shouldn’t break parsing. If the pipeline operator is expected to be on the same indent level - it’s expected to work in each case
I think it's a bug - it should work without indentation!
and we talked in some other thread about how the formatter shouldn't indent it in this scenario
Luke Boswell said:
I just tested with the block changes -- it's still there
Please ignore this comment.
The error message we see is from Can, so it's definitely possible this is fixed, or the parsing parts in Josh's work.
I'm running off my stale memory of this issue. Need to dig a bit more before I comment next time.
Just tested this on the current main (after my block parsing PR landed), and the syntax tree at least looks correct to me:
main =
Arg.list! {}
|> List.dropFirst 1
|> List.mapTry Str.toU8
|> Task.fromResult!
|> List.sum
|> \total -> "Sum of numbers: $(Num.toStr total)"
|> Stdout.line!
(which is to say, it parses fine and gives a sequence of exprs joined by pizza operators, all at the same level... does that sound right?)
That's not true prior to my PR (just checked that as well) - it used to choke on the first pizza operator. So there was definitely an improvement here.
I _think_ that's what you were saying Luke; just wanted to make it explicit / make sure we're on the same page...
Thank you, yes that's what I was trying to say.
Last updated: Jul 06 2025 at 12:14 UTC