Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pizza pipe not working #7530

Closed
1 task
Anton-4 opened this issue Jan 18, 2025 · 4 comments
Closed
1 task

pizza pipe not working #7530

Anton-4 opened this issue Jan 18, 2025 · 4 comments
Labels
P-high High priority/frequency

Comments

@Anton-4
Copy link
Collaborator

Anton-4 commented Jan 18, 2025

Error message:

$ roc check temp.roc
── TOO FEW ARGS in temp.roc ────────────────────────────────────────────────────

The first function expects 1 argument, but it got only 0:

4│      ["hello"] |> List.first()?
                     ^^^^^^^^^^

Roc does not allow functions to be partially applied. Use a closure to
make partial application explicit.

────────────────────────────────────────────────────────────────────────────────

1 error and 0 warnings found in 13 ms.
module [something]

something = |_|
    ["hello"] |> List.first()?

This version does work:

module [something]

something = |_|
    ["hello"] |> List.first()

If we look at the desugared version we'll probably be able to make sense of this.

  • We should add a test for this failure once fixed.
@Anton-4 Anton-4 added the P-high High priority/frequency label Jan 18, 2025
@Anton-4
Copy link
Collaborator Author

Anton-4 commented Jan 18, 2025

@Anton-4 Anton-4 self-assigned this Jan 20, 2025
@Anton-4
Copy link
Collaborator Author

Anton-4 commented Jan 20, 2025

The desugared version of

module [something]

something = |_|
    ["hello"] |> List.first()?

Is:

Body(
            @20-29 Identifier {
                ident: "something",
            },
            @32-66 Closure(
                [
                    @33-34 Underscore(
                        "",
                    ),
                ],
                @40-65 LowLevelTry(
                    @40-65 Apply(
                        @53-65 PncApply(
                            @53-63 Var {
                                module_name: "List",
                                ident: "first",
                            },
                            [],
                        ),
                        [
                            @40-49 List(
                                [
                                    @41-48 Str(
                                        PlainLine(
                                            "hello",
                                        ),
                                    ),
                                ],
                            ),
                        ],
                        Try,
                    ),
                    OperatorSuffix,
                ),
            ),
        )

The desugared version of:

module [something]

something = |_|
    ["hello"] |> List.first()

Is:

Body(
            @20-29 Identifier {
                ident: "something",
            },
            @32-65 Closure(
                [
                    @33-34 Underscore(
                        "",
                    ),
                ],
                @40-65 Apply(
                    @53-63 Var {
                        module_name: "List",
                        ident: "first",
                    },
                    [
                        @40-49 List(
                            [
                                @41-48 Str(
                                    PlainLine(
                                        "hello",
                                    ),
                                ),
                            ],
                        ),
                    ],
                    BinOp(
                        Pizza,
                    ),
                ),
            ),
        )

@Anton-4 Anton-4 removed their assignment Jan 25, 2025
@Anton-4
Copy link
Collaborator Author

Anton-4 commented Jan 25, 2025

Recommended workaround:
Change

module [something]

something = |_|
    ["hello"] |> List.first()?

To:

module [something]

something = |_|
    List.first(["hello"])

@Anton-4
Copy link
Collaborator Author

Anton-4 commented Jan 25, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P-high High priority/frequency
Projects
None yet
Development

No branches or pull requests

1 participant