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

Amend 475 to use ghc-experimental for exports #603

Merged
merged 10 commits into from Sep 18, 2023

Conversation

tek
Copy link
Contributor

@tek tek commented Jul 11, 2023

Motivated by recent conversations with the CLC about stability of the API of base, we devised the plan to introduce a new package, ghc-experimental, that shall become the initial home for exports of new entities that should be tried out by the community before committing to a stable API.

This amendment changes the modules exporting the new tuple- and sum-related entities to use that new package.

I'd appreciate feedback, in particular about whether the creation of this package should be part of the proposal or be handled separately, and whether the deprecation of ghc-prim:GHC.Tuple for the rename to GHC.Internal.Tuple should be included here.

@simonpj
Copy link
Contributor

simonpj commented Jul 11, 2023

Looks good to me.

many *unsafe* internals.

This proposal lists several definitions to be exported from ``GHC.Prelude``, but leaves other
definitions to be added in separate proposal(s).

``GHC.Tuple`` will clash with the same module from ``ghc-prim``.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we avoid the clashes? Nothing compels us to create a conflicting GHC.Tuple in ghc-experimental, at least not for the sake of this proposal. Just leave it in ghc-prim?

The new GHC.Sum and GHC.Prelude can go to ghc-experimental, of course, as there is no conflict.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we avoid the clashes? Nothing compels us to create a conflicting GHC.Tuple in ghc-experimental, at least not for the sake of this proposal. Just leave it in ghc-prim?

Good qn. But if we leave it in ghc-prim then clients of the new tuple stuff will be force to depend on ghc-prim which we do not want. Rather, I think we should transition ghc-prim:GHC.Tuple to become ghc-prim:GHC.Internals.Tuple. Quite how fast we do that isn't clear to me.

@goldfirere ?

Copy link
Contributor Author

@tek tek Jul 12, 2023

Choose a reason for hiding this comment

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

our new GHC.Tuple depends on base (it needs TypeNats and possibly TypeError), so leaving it in ghc-prim is a no-go.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

now that the module naming scheme is clear, GHC.Tuple can stay in ghc-prim!

peculiar to GHC that are safe to use in ordinary code.
This module is *not* intended as a replacement to ``Prelude``,
but instead a complement to it. This module is a counterpart to ``GHC.Exts``, which exports
1. Create three new modules in ``ghc-experimental`` called ``GHC.Prelude``,
Copy link
Contributor

@int-index int-index Jul 11, 2023

Choose a reason for hiding this comment

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

GHC.Prelude is actually taken by the GHC API for the custom Prelude used by GHC itself. Are we absolutely sure we want to repurpose this name, when we could simply pick a different one? Need opinion from @goldfirere

Copy link
Contributor

Choose a reason for hiding this comment

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

Huh -- that is annoying.

It demonstrates that we are using the module prefix "GHC." in two different ways:

  • Modules of GHC itself (e.g. GHC.Core.Opt.Simplify)
  • Modules in ghc-experimental.
    These are not the same purpose.

Maybe ghc-experimental should start with GHCX.? Thus GHCX.Prelude, GHCX.Tuple. Or some other prefix?

Copy link
Contributor

@int-index int-index Jul 11, 2023

Choose a reason for hiding this comment

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

GHCX.* is just a slightly different take on GHC.Exts.* that @tek previously suggested, right? I believe GHC.Exts.* is good and descriptive. For example, GHC.Exts.Tuple is "GHC's extensions to tuples". When those get stabilized, they can be reexported from Data.Tuple (with CLC's approval)

Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder about the broader situation here - would the idea be that all GHC.Exts.* modules/names end up in non-GHC.Exts.* modules if/when brought into base? Since if anything is added to base also under the GHC.Exts.* moniker, you would still end up with a naming conflict during the deprecation period from ghc-experimental (edit: actually I suppose there might not be a deprecation period if it's just reexported from base, and stays in ghc-experimental, but that doesn't affect my question I think)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

GHC.Exts exposes some unsafe operations, as in "crash the process" unsafe, which the original text uses as contrast for the purpose of GHC.Prelude…would calling the new namespace GHC.Exts.* associate ghc-experimental with that notion?

On the other hand, GHC.Exts might be a candidate for migration to ghc-internals.

There is also a large number of GHC.* modules in base that might be a source for additional conflicts later.

Copy link
Contributor

Choose a reason for hiding this comment

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

I find the prefix GHC. for things in ghc-experimental strange, as they are neither about GHC (e.g. a plugins) or part of GHC (e.g. GHC.Prelude). It's as if I start to prefix my library modules with Nomeata.. I expect developers to find this naming confusing (me already included.)

How about we append Experimental to the module name from base where things might end up in? Data.Tuple.Experimental?

Copy link
Contributor

Choose a reason for hiding this comment

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

The only thing is should GHC's experiments have a monopoly on such names?

Data.Tuple.GlasgowExperiment lol

What it is comes first, "compilation" is not relevant and thus unmentioned, who experiment and so not to conflict with other experiments comes last.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

now called Prelude.Experimental.

@simonpj
Copy link
Contributor

simonpj commented Jul 13, 2023

How about we append Experimental to the module name from base where things might end up in? Data.Tuple.Experimental?

Or prefix it, so that ghc-experimental modules are in the Experimental.* name space. Thus Experimental.Data.Tuple.

(I can't speak for others but I'm quite open to renaming the library itself too, incidentally, but just experimental sounds a bit too generic.)

@numlit2
Copy link

numlit2 commented Jul 13, 2023

Or prefix it, so that ghc-experimental modules are in the Experimental.* name space. Thus Experimental.Data.Tuple.

Experimental.* is very good. I know I will import something unstable. GHC.Exts.*doesn't tell me anything.

@adamgundry
Copy link
Contributor

This somewhat overlaps with the discussion at haskellfoundation/tech-proposals#53.

I would suggest we use Prelude.Experimental, Data.Tuple.Experimental and Data.Sum.Experimental. Moreover we could have Prelude.Experimental export Type (cf. haskell/core-libraries-committee#193).

@tek
Copy link
Contributor Author

tek commented Aug 3, 2023

That seems like a reasonable schema to me, and it saves us the discussion about GHC.Prelude.

But exporting Type from there sounds like it would become its permanent home – the problem articulated in the other discussion isn't that Type isn't available in base, but that it isn't implicitly in scope, no?

@adamgundry
Copy link
Contributor

the problem articulated in the other discussion isn't that Type isn't available in base, but that it isn't implicitly in scope, no?

Indeed, so the benefits are limited. I was just thinking about what else Prelude.Experimental could reasonably export, as a "staging ground" for things that may be added to Prelude later. It's fine if you prefer to leave that discussion for a separate proposal.

@tek
Copy link
Contributor Author

tek commented Aug 25, 2023

@tek tek force-pushed the 475-amendment branch 5 times, most recently from 29ee893 to 3579d91 Compare August 28, 2023 18:02
@tek
Copy link
Contributor Author

tek commented Aug 29, 2023

@nomeata would you submit, please?

@nomeata
Copy link
Contributor

nomeata commented Aug 29, 2023

I am not sure if this needs the full committee process. Isn’t it the only reasonable choice given the (accepted) plan around the use of ghc-experimental?

If @simonpj or @adamgundry could sanity-check the diff I’m inclined to just merge as it.

Copy link
Contributor

@adamgundry adamgundry left a comment

Choose a reason for hiding this comment

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

Thank you for pushing this on @tek! I have a few minor nitpicks but I agree that a full committee review seems unnecessary given that most of this is essentially predetermined.

I'm wondering whether it helps or hinders to give all the fully-qualified module names referring to modules in ghc-prim. Arguably, where things live in ghc-prim/ghc-internals are implementation details that needn't be part of the specification, provided we are clear about what is being exposed from base (nothing?) and ghc-experimental. But I'll leave this up to your preference.

the definitions below in ``GHC.Tuple`` on ``GHC.TypeLits``.) ::
#. Export the following definitions from ``Data.Tuple.Experimental`` and
``Prelude.Experimental``. (Implementation note: These would probably end up
in a new module ``Data.Tuple.Prim``, due to the dependency from
Copy link
Contributor

Choose a reason for hiding this comment

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

Was this renaming intended? Further down the proposal still refers to GHC.Tuple.Prim. Given the name I assume this would be a new module in ghc-prim, but it wouldn't hurt to be explicit. It's not obvious to me why we need all of GHC.Prim, GHC.Tuple and GHC.Tuple.Prim, but those are implementation details that aren't essential to the specification anyway.

Suggested change
in a new module ``Data.Tuple.Prim``, due to the dependency from
in a new module ``GHC.Tuple.Prim``, due to the dependency from

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah, now that we use Data.Tuple.Experimental instead of GHC.Tuple (which was supposed to move to base), we could probably use the latter for the new definitions instead of GHC.Tuple.Prim. I'll change that and see if it creates any issues.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

works!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah, but GHC.Tuple.Prim is already in master due to an older MR that implements only a small part of the proposal – should we discard it anyway and break the API of ghc-prim?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@adamgundry what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think ghc-prim has no stability guarantees, so you should feel free to remove GHC.Tuple.Prim unless there is some implementation reason to keep it.

where there are *n-1* commas.

#. An occurrence of ``GHC.Exts.Unit#`` is pretty-printed as ``(# #)``.
#. An occurrence of ``GHC.Types.Unit#`` is pretty-printed as ``(# #)``.
Copy link
Contributor

Choose a reason for hiding this comment

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

We seemingly have GHC.Types.Unit# here, but GHC.Exts.Unit# elsewhere, and when Unit# is introduced it says it "would likely be exported from GHC.Prim originally". (And similarly for the other types.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

those should all have been changed to GHC.Types, I overlooked a few occurrences.
GHC.Prim is a virtual module, so my assumption is that Richard hadn't determined the precise module yet at the point of writing it.

The straightforward change would have been to use Data.Tuple.Experimental instead of GHC.Exts – I used GHC.Types because I now know what we landed on eventually…do you think that's too much retconning? We could also change the other sentence to say "would likely be exported from GHC.Types originally".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah no, there's no equivalent of GHC.Exts with the new schema…

proposals/0475-tuple-syntax.rst Show resolved Hide resolved
tek and others added 3 commits August 29, 2023 20:03
@simonpj
Copy link
Contributor

simonpj commented Aug 29, 2023

Please could the propsal say clearly

  1. What are the changes to the API of base?
  2. What are the changes to the API of ghc-experimental?
  3. What other changes to ghc-internal packages are there? E.g. to the union of ghc-internal and ghc-prim? True, this doesn't need to be part of the specification, since it's an implementation matter, and it should be explained as such.

Currently all these changes are mixed together, and only module names are given, not packages, so I can't work out the answer. Could you simply summarise in one place?

I think there is quite a bit of (1) changes, and they need agreement from CLC. E.g. changes to GHC.List.

I notice mention of GHC.Tuple.Prim. What package is that in? And I thought we'd agreed that ghc-internal modules would usually look like GHC.Internal.Tuple?

@adamgundry
Copy link
Contributor

adamgundry commented Aug 30, 2023

I think there is quite a bit of (1) changes, and they need agreement from CLC. E.g. changes to GHC.List.

Good point. I was assuming there would be no base changes, which I think would be the case if point 10 was adapted so that GHC.List would not re-export List? (And the references to GHC.List.List changed to GHC.Types.List.)

EDIT: actually, I realise now that GHC.List already exports List; and indeed there is a proposal to have Data.List do so (haskell/core-libraries-committee#182).

@simonpj
Copy link
Contributor

simonpj commented Aug 31, 2023

I think that, more than just edinting point 10, it would help the reader a lot if there was a brief summy of

  • Changes to ghc-experimental
  • Changes to base

The existing structure is fine; just a summary is needed so that the reader can quickly get that overview.

@tek
Copy link
Contributor Author

tek commented Aug 31, 2023

I used the libraries section we added to the template last week. Other than List, there's no change to base.

Copy link
Contributor

@adamgundry adamgundry left a comment

Choose a reason for hiding this comment

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

Apart from a couple of RST syntax nits this looks good to me, thanks @tek!

@simonpj are you happy with the revised state? AFAICS there is no need for further CLC consultation as the only change to base is the export of List from GHC.List, which has already been implemented.

#. Export the following definitions from ``GHC.Exts`` and ``GHC.Prelude``. These replace
the existing tuple definitions (in ``GHC.Classes``) today. (Note that ``(...) =>`` is special syntax, and does not
#. Replace the existing constraint tuples in ``GHC.Classes`` with the following
definitions and export them from ``Data.Tuple.Experimental`` and ``Prelude.Experimental``. ::
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
definitions and export them from ``Data.Tuple.Experimental`` and ``Prelude.Experimental``. ::
definitions and export them from ``Data.Tuple.Experimental`` and ``Prelude.Experimental``.

Comment on lines 351 to 354
#. ``ghc-experimental``:
- ``Data.Tuple.Experimental`` will export all tuple-related entities.
- ``Data.Sum.Experimental`` will export all sum-related entities.
- ``Prelude.Experimental`` will export all of the above.
Copy link
Contributor

Choose a reason for hiding this comment

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

The RST list syntax is somehow not quite right here.

the definitions below in ``GHC.Tuple`` on ``GHC.TypeLits``.) ::
#. Export the following definitions from ``Data.Tuple.Experimental`` and
``Prelude.Experimental``. (Implementation note: These would probably end up
in a new module ``Data.Tuple.Prim``, due to the dependency from
Copy link
Contributor

Choose a reason for hiding this comment

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

I think ghc-prim has no stability guarantees, so you should feel free to remove GHC.Tuple.Prim unless there is some implementation reason to keep it.

Copy link
Contributor

@simonpj simonpj left a comment

Choose a reason for hiding this comment

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

Generally fine, thank you. Just cosmetic suggestions.

This proposal lists several definitions to be exported from ``Prelude.Experimental``,
but leaves other definitions to be added in separate proposal(s).

All of the wired-in types must be declared in ``ghc-prim``, and re-exported from
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't part of the specification -- it's an implementation note. Mabye

Implementation note: many type definitions will be "wired-in", defined in `ghc-prim`, and simply re-exported from `ghc-experimental`.

These would probably end up in a new module ``GHC.Tuple.Prim``, due to the dependency from
the definitions below in ``GHC.Tuple`` on ``GHC.TypeLits``.) ::
#. Replace the existing tuples in ``GHC.Tuple`` with the following definitions
and export them from ``Data.Tuple.Experimental`` and ``Prelude.Experimental``. ::
Copy link
Contributor

Choose a reason for hiding this comment

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

I would not talk about replacing anything. That's an implementation matter. Perhaps just

Export the following type definitions from `Data.Tuple.Experimental`.

``Prelude.Experimental`` exports definitions peculiar to GHC that are safe to
use in ordinary code, but whose API may evolve rapidly over subsequent releases.
This module is *not* intended as a replacement to ``Prelude``, but instead a
complement to it. This module is a counterpart to ``GHC.Exts``, which exports
many *unsafe* internals.
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhpas add

`Prelude.Experimental` simple re-exports the all the exports of `Data.Tuple.Experimental` and `Data.Sum.Experimental`, thus
   module Prelude.Experimental (
       module Data.Tuple.Experimental,
       module Data.Sum.Experimental
    ) where 
     import Data.Tuple.Experimental
    import Data.Sum.Experimental

Now you don't need to talk about `Prelude.Experimental` any futher.

In fact you could specify `Prelude.Experimental` as a separate bullet.

#. Export the following definitions from ``GHC.Exts`` and ``GHC.Prelude``. These replace
the existing tuple definitions (in ``GHC.Classes``) today. (Note that ``(...) =>`` is special syntax, and does not
#. Replace the existing constraint tuples in ``GHC.Classes`` with the following
definitions and export them from ``Data.Tuple.Experimental`` and ``Prelude.Experimental``. ::
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment. Don't talk about replacing or about GHC.Classes. Those are implementation matters. Simply write down the definitions visible through Data.Tuple.Experimental.

@simonpj
Copy link
Contributor

simonpj commented Sep 13, 2023

@simonpj are you happy with the revised state? AFAICS there is no need for further CLC consultation as the only change to base is the export of List from GHC.List, which has already been implemented.

I agree we don't need to consult but I think it would be polite to send an email to the CLC mailing list, drawing their attention to these changes.

@tek
Copy link
Contributor Author

tek commented Sep 13, 2023

@adamgundry @simonpj I believe I have implemented all your suggestions, and sent an email to the CLC.

Co-authored-by: Adam Gundry <adam@well-typed.com>
@nomeata
Copy link
Contributor

nomeata commented Sep 13, 2023

@adamgundry , shall I merge?

@tomjaguarpaw
Copy link
Contributor

There's something I don't understand here. Apparently there is one change to base: "GHC.List will export GHC.Types.List". But GHC.List already exports GHC.Types.List so I don't understand why that's part of the proposal. Perhaps it's supposed to be explained by the following text

The proposal and the implementation of the List part predate the stability practice of introducing experimental entities in ghc-experimental.

but I don't understand what "the List part" means or why that should explain this particular aspect of the proposal.

@tomjaguarpaw
Copy link
Contributor

(Please don't hold up moving forward with this proposal on my account. It's probably just me being dim or having forgotten something I knew about before. But the CLC was explicitly informed of this proposal and this CLC member doesn't understand the one small part that seems to impinge on the CLC.)

@tek
Copy link
Contributor Author

tek commented Sep 13, 2023

@tomjaguarpaw that's just to say that the implementation of the part of the proposal that introduces List and exports it from base was already merged to master and released before we started the split-base discussion and decided to refrain from exporting these new entities from base.

@tomjaguarpaw
Copy link
Contributor

So #475 was partially implemented and now you're revising it so that the rest of the implementation uses ghc-experimental instead?

@tek
Copy link
Contributor Author

tek commented Sep 13, 2023

@tomjaguarpaw that's correct

@tomjaguarpaw
Copy link
Contributor

Great, thanks for clarifying!

@tek
Copy link
Contributor Author

tek commented Sep 14, 2023

small tweak: mentioned Solo deprecation explicitly in the library changes section.

@adamgundry
Copy link
Contributor

@adamgundry , shall I merge?

LGTM, yes please!

@nomeata nomeata merged commit 0c76676 into ghc-proposals:master Sep 18, 2023
@tek tek deleted the 475-amendment branch September 18, 2023 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants