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

Unify Nat and Natural #364

Merged
merged 4 commits into from Oct 12, 2020
Merged

Unify Nat and Natural #364

merged 4 commits into from Oct 12, 2020

Conversation

goldfirere
Copy link
Contributor

@goldfirere goldfirere commented Sep 15, 2020

The proposal has been accepted; the following discussion is mostly of historic interest.


This proposal is an attempt to unblock https://gitlab.haskell.org/ghc/ghc/-/merge_requests/3583, which is user-facing and requires some broader consultation.

Rendered

Copy link
Contributor

@RyanGlScott RyanGlScott left a comment

Choose a reason for hiding this comment

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

I think the cut of this proposal's jib. I've left two minor suggestions inline.

proposals/0000-unify-natural.rst Outdated Show resolved Hide resolved
proposals/0000-unify-natural.rst Show resolved Hide resolved
is implied by ``FlexibleInstances``. Or, they could be written to use ``Natural``
instead of ``Nat``.

Otherwise, this change should be backward compatible.
Copy link
Contributor

Choose a reason for hiding this comment

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

That's not the full story, the following code will also break:

class C a
instance C Nat
instance C Natural

Now these instances conflict with one another.

@goldfirere
Copy link
Contributor Author

Any more commentary before submitting this to committee? Seems pretty straightforward.

@int-index
Copy link
Contributor

Any more commentary before submitting this to committee?

None from me or @Haskell-mouse. Looks good, thank you!

@goldfirere
Copy link
Contributor Author

Let's submit then, @nomeata .

@nomeata nomeata added the Pending shepherd recommendation The shepherd needs to evaluate the proposal and make a recommendataion label Sep 25, 2020
@nomeata
Copy link
Contributor

nomeata commented Sep 25, 2020

/remind @serras to ensure progress in two weeks

@reminders-prs
Copy link

reminders-prs bot commented Sep 25, 2020

@nomeata set a reminder for Oct 9th 2020

@aspiwack
Copy link
Contributor

The cost of this proposal is mightily low (there is a small, already ready MR, which has essentially 0 net lines of code).

So I'd see the bar to pass to be just as low.

However, I think that the motivation would be quite a bit more readable, and will stand the test of time better, with a tiny bit of code illustrating the difficulty.

@jvanbruegge
Copy link

Are there any plans concerning Symbol/String (or maybe Text)? They have basically the same issue. Or would we want to wait for something that allows overloading type level strings? I remember that there was a proposal for this, but no idea what the status is

@int-index
Copy link
Contributor

Are there any plans concerning Symbol/String (or maybe Text)?

There's ongoing work to make the promotion of Char possible, this way you also get String.

However, Symbol is more efficient than String, so we can't just unify them as we unify Nat and Natural here. This will require more thought, and a separate proposal. Personally, I like the idea of making Symbol inhabited at the term level by UTF-8 encoded strings.

@goldfirere
Copy link
Contributor Author

@int-index You and colleagues (I don't have their GitHub usernames) are the instigators here. Would you care to write a better motivation section? Feel free just to push to my branch -- it seems you already have access.

@serras serras added Pending committee review The committee needs to evaluate the proposal and make a decision and removed Pending shepherd recommendation The shepherd needs to evaluate the proposal and make a recommendataion labels Oct 1, 2020
@serras serras changed the title Unify Nat and Natural Unify Nat and Natural (under review) Oct 1, 2020
@serras
Copy link
Contributor

serras commented Oct 1, 2020

My recommendation is to accept this proposal.

Apart from the small comment by @goldfirere, I think it would be nice for the proposal to point our that neither Natural nor the old Nat kind implement Peano naturals, so people should not expect to be able to decompose them.

@int-index
Copy link
Contributor

@aspiwack I've added an example to the Motivation section. How is it looking now?

@Ericson2314
Copy link
Contributor

Are there any plans concerning Symbol/String (or maybe Text)?

There's ongoing work to make the promotion of Char possible, this way you also get String.

However, Symbol is more efficient than String, so we can't just unify them as we unify Nat and Natural here. This will require more thought, and a separate proposal. Personally, I like the idea of making Symbol inhabited at the term level by UTF-8 encoded strings.

Yeah to me the "right" way to do this is dramatically more work than this proposal and should be discussed separately. (I would want promoted IsString so we don't have to bloat base further.)

@aspiwack
Copy link
Contributor

aspiwack commented Oct 2, 2020

@aspiwack I've added an example to the Motivation section. How is it looking now?

It's the sort of things I had in mind. Thanks.

@reminders-prs reminders-prs bot removed the reminder label Oct 9, 2020
@reminders-prs
Copy link

reminders-prs bot commented Oct 9, 2020

👋 @serras, ensure progress

@int-index
Copy link
Contributor

@nomeata @serras What's the status here?

@nomeata
Copy link
Contributor

nomeata commented Oct 12, 2020

There seems to be pretty clear consensus on the commitee, I’ll mark this as accepted.

@nomeata nomeata merged commit 22c30c8 into ghc-proposals:master Oct 12, 2020
@nomeata nomeata added Accepted The committee has decided to accept the proposal and removed Pending committee review The committee needs to evaluate the proposal and make a decision labels Oct 12, 2020
@nomeata nomeata changed the title Unify Nat and Natural (under review) Unify Nat and Natural Oct 12, 2020
@nomeata nomeata added the Implemented The proposal has been implemented and has hit GHC master label Jul 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted The committee has decided to accept the proposal Implemented The proposal has been implemented and has hit GHC master
Development

Successfully merging this pull request may close these issues.

None yet

10 participants