Skip to content

[list-ops] Make foldl' call unambiguous.#1298

Open
IsaacG wants to merge 3 commits into
exercism:mainfrom
IsaacG:listops
Open

[list-ops] Make foldl' call unambiguous.#1298
IsaacG wants to merge 3 commits into
exercism:mainfrom
IsaacG:listops

Conversation

@IsaacG

@IsaacG IsaacG commented May 16, 2026

Copy link
Copy Markdown
Member
/solution/test/Tests.hs:80:9: error: [GHC-87543]
    Ambiguous occurrence ‘foldl'’.
    It could refer to
       either ‘Prelude.foldl'’,
              imported from ‘Prelude’ at test/Tests.hs:(8,1)-(16,5)
              (and originally defined in ‘ghc-internal-9.1003.0:GHC.Internal.Data.Foldable’),
           or ‘ListOps.foldl'’,
              imported from ‘ListOps’ at test/Tests.hs:22:7-12.
   |
80 |         foldl' (flip (:)) [] "asdf" `shouldBe` "fdsa"
   |         ^^^^^^

@github-actions

Copy link
Copy Markdown

This PR touches files which potentially affect the outcome of the tests of an exercise. This will cause all students' solutions to affected exercises to be re-tested.

If this PR does not affect the result of the test (or, for example, adds an edge case that is not worth rerunning all tests for), please add the following to the merge-commit message which will stops student's tests from re-running. Please copy-paste to avoid typos.

[no important files changed]

For more information, refer to the documentation. If you are unsure whether to add the message or not, please ping @exercism/maintainers-admin in a comment. Thank you!

@MatthijsBlom MatthijsBlom left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a [no important files changed] would be fitting.


Prior to base-4.20.0.0 (bundled with GHC 9.10), foldl' was not re-exported by the Prelude. But from base-4.20.0.0 onward it is, hence the error that the proposed change fixes.

All other names defined in ListOps were already exported by the Prelude. This conflict was solved by hiding these while importing the Prelude. Rather than disambiguating all its uses, add foldl' to this import list.


The solution stub file should be patched as well.

@IsaacG

IsaacG commented May 16, 2026

Copy link
Copy Markdown
Member Author

I think a [no important files changed] would be fitting.

I completely agree. That needs to be in the merge message when the track maintainer merges this PR.

The solution stub file should be patched as well.

Done.

Thanks for the explanation and details!

@MatthijsBlom

MatthijsBlom commented May 16, 2026

Copy link
Copy Markdown
Contributor

Both …/list-ops/.meta/…/ListOps.hs and …/list-ops/test/Tests.hs are good now.

By "the solution stub file" I meant …/list-ops/src/ListOps.hs. That one should receive the same patch as the other two.


Hiding a nonexistent export gives rise to merely a GHC-61689 -Wdodgy-imports warning, so it looks like this change is backwards-compatible.


...Except apparently the tests have -Werror=dodgy-imports. I guess as a consequence of a -Werror=all or something somewhere.

@IsaacG

IsaacG commented May 16, 2026

Copy link
Copy Markdown
Member Author

By "the solution stub file" I meant …/list-ops/src/ListOps.hs. That one should receive the same patch as the other two.

Woops. Missed that one. Added now.

@IsaacG

IsaacG commented May 16, 2026

Copy link
Copy Markdown
Member Author

Eh. This PR was meant in service of the test runner upgrade. If that lands first, a test rerun ought to pass here.

Unrelated, there's a bunch of other PRs in this repo worth a look, too!

@MatthijsBlom

Copy link
Copy Markdown
Contributor

I think the tests fail because of

--pedantic `# Enable -Wall and -Werror. `\

I guess they could be made to pass again by adding --ghc-options="-Wwarn=dodgy-imports" to that stack call.
But we could also just wait until the track moves on to use base-4.20+ (GHC 9.10+).

@IsaacG

IsaacG commented Jun 6, 2026

Copy link
Copy Markdown
Member Author

@tofische With the test runner updated, it might be worth rerunning the failed check here

@IsaacG

IsaacG commented Jun 8, 2026

Copy link
Copy Markdown
Member Author

@exercism/haskell Could you rerun the failed test now that the test runner has been updated?

@MatthijsBlom

Copy link
Copy Markdown
Contributor

The exercises check failure is expected. This PR adds a nonexistent item to import lists. GHC raises a warning about this, and the exercises check elevates all warnings to errors. The warning will go away as soon as the test runner is moved on to use GHC 9.10 / base 4.20.

The configuration check failure confuses me.

@tofische

Copy link
Copy Markdown
Contributor

The configuration check failure confuses me.

The path doesn't contain the flower-field exercise that was added later. @IsaacG rebase and push again, it shall IMHO help.

@MatthijsBlom

Copy link
Copy Markdown
Contributor

Ah, so it is this line that causes flower-field to show up:

git diff --name-only "origin/main..$branch_name" | \

IsaacG added 3 commits June 10, 2026 07:55
```
/solution/test/Tests.hs:80:9: error: [GHC-87543]
    Ambiguous occurrence ‘foldl'’.
    It could refer to
       either ‘Prelude.foldl'’,
              imported from ‘Prelude’ at test/Tests.hs:(8,1)-(16,5)
              (and originally defined in ‘ghc-internal-9.1003.0:GHC.Internal.Data.Foldable’),
           or ‘ListOps.foldl'’,
              imported from ‘ListOps’ at test/Tests.hs:22:7-12.
   |
80 |         foldl' (flip (:)) [] "asdf" `shouldBe` "fdsa"
   |         ^^^^^^
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants