haskell / core-libraries-committee

95 stars 15 forks source link

Export `Data.Traversable.for` from the Prelude #256

Closed mixphix closed 3 weeks ago

mixphix commented 6 months ago

Merge request

I did not test clc-stackage as there are many packages with version bounds in both the current cabal file and the latest Stackage Nightly release that do not include base-4.19.

phadej commented 6 months ago

I did not test clc-stackage as there are many packages with version bounds in both the current cabal file and the latest Stackage Nightly release that do not include base-4.19.

That is very bad excuse. You are a member of CLC, if you don't bother to do that yourself, dont' ask anyone else either.

E.g. it looks that

Bodigrim commented 1 month ago

@mixphix could you please give another go to https://github.com/haskell/clc-stackage? I was able to build it in full recently.

(You'd have to backport your changes from GHC master to ghc-9.8 branch, there is no newer Stackage)

tomjaguarpaw commented 1 month ago

If we're going to do this kind of thing could it be done based on an assessment of what actually gets imported from non-Prelude base libraries in practice?

mixphix commented 1 month ago

I'm not sure I understand what you mean, @tomjaguarpaw. Should we open a poll on the Discourse for this? Perhaps we can include some other functions in the poll and export the top 3. Personally, as the proposal author, exporting for is enough for me.


@Bodigrim I'll give it a try this week, thanks for the update.

tomjaguarpaw commented 1 month ago

I was thinking of doing an analysis of all code on Hackage to determine which identifiers are most imported from modules in base and adding the most commonly imported ones to the Prelude (in the absence of obvious name clashes, etc.).

mixphix commented 1 month ago

Am I to assume that these maintainers will want such imports to disappear? Many heavy-duty libraries in the Haskell ecosystem still emit warnings from before the Functor–Applicative–Monad proposal. Those who object to this, much smaller, scope, can do so in this thread dedicated to exporting for from the Prelude. Until then, please refrain from derailing it.

tomjaguarpaw commented 1 month ago

As you wish. I think your proposal would be much stronger if it was backed by numerical evidence, but you're free to manage it as you prefer, of course.

chessai commented 1 month ago

I would like to express a weak preference against this, because I have always felt that Data.Traversable.for is a misnomer in a world where we have forM = flip mapM. I have always wanted for = flip Data.List.map.

phadej commented 1 month ago

I would like to express a weak preference against this, because I have always felt that Data.Traversable.for is a misnomer in a world where we have forM = flip mapM. I have always wanted for = flip Data.List.map.

Sure, it would been more consistent to have Functor with map (and for) (and have the monomorphic Data.List.map not in the prelude), Traversable with mapA/forA (Applicative) and mapM/forM; but that renaming won't happen; so I guess the ecosystem is stuck with the current naming scheme.

mixphix commented 1 month ago

@Bodigrim I am unable to access my GitLab account because I cleared my 2FA app and lost my recovery codes. Who can I contact to resolve this?

Bodigrim commented 1 month ago

@mixphix the best is to drop a message to https://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs, but also CC @chreekat.

treeowl commented 1 month ago

Isn't for used for some streaming/iteration stuff? It doesn't strike me as a great word to steal.

mixphix commented 1 month ago

I want to reiterate that this for is the one from Data.Traversable, which permits Applicative actions.

chreekat commented 1 month ago

@mixphix did you get access to GitLab yet?

mixphix commented 1 month ago

@chreekat Unfortunately not, I was forbidden from emailing the ghc-devs mailing list and received no response from ghc-devs-owner.

chreekat commented 1 month ago

@mixphix ok, can you email me at bryan@haskell.foundation from the email address associated with your account?

mixphix commented 1 month ago

I've sent you an email.

mixphix commented 1 month ago

I was able to log in and set up 2FA again. Thanks @chreekat and @Bodigrim. I've left a comment on the MR thread as well.

mixphix commented 1 month ago

After compiling as much of clc-stackage as I could with the GHC using the changes from this MR, I found 27 ambiguities in 14 packages:

Should the proposal pass, these are the libraries I'll submit pull requests to.

Bodigrim commented 1 month ago

Thanks! Note that the proposal process asks for patches to be prepared upfront (but not submitted as PRs):

To be more specific, pipes and streaming are dependencies of many packages, so it would be really important to patch them locally (cabal unpack them somewhere, patch and add the folder to cabal.project) to progress further.

What's the suggested migration guide for pipes and streaming? Both APIs contain for functions, incompatible with Prelude: Pipes and Streaming.Prelude. At least Pipes are often imported unqualified. Should they be advised to rename the combinator (which is a breaking change for them and consumers)? Or should consumers be advised to import Pipes qualified? Or just keep import Prelude hiding (for) everywhere for foreseeable future?

Same question for other packages offering for in public API, see https://www.stackage.org/lts-22.33/hoogle?q=for for an approximate list. I suspect that quite a few of them are usually imported unqualified.

mixphix commented 3 weeks ago

I am still not able to compile a full working version of clc-stackage with the GHC 9.8 produced from altering the Prelude, due to more errors from the constraint solver than from the ambiguities, which works out to be closer to 40 packages with dependencies, especially from pipes and streaming ecosystems. This has been much more effort than writing import Data.Traversable (for) in the source files I need.