Skip to content

Introduce Data.Enum and Data.Bounded #208

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

Closed
bgamari opened this issue Sep 20, 2023 · 19 comments
Closed

Introduce Data.Enum and Data.Bounded #208

bgamari opened this issue Sep 20, 2023 · 19 comments
Labels
approved Approved by CLC vote base-4.20 Implemented in base-4.20 (GHC 9.10) base-4.21 Implemented in base-4.21 (GHC 9.12)

Comments

@bgamari
Copy link

bgamari commented Sep 20, 2023

In #146 I noticed that the Enum and Bounded typeclasses currently have no proper home (currently exposed only via Prelude and GHC.Enum). I propose that we remedy this by introducing a pair of new modules, Data.Bounded and Data.Enum, to base:

module Data.Bounded where

class Bounded a where
  minBound :: a
  maxBound :: a

module Data.Enum where

class Enum a where
  succ :: a -> a
  pred :: a -> a
  toEnum :: GHC.Types.Int -> a
  fromEnum :: a -> GHC.Types.Int
  enumFrom :: a -> [a]
  enumFromThen :: a -> a -> [a]
  enumFromTo :: a -> a -> [a]
  enumFromThenTo :: a -> a -> a -> [a]

This has been implemented in !10422 and !11347.

@mixphix
Copy link
Collaborator

mixphix commented Sep 21, 2023

+1, and please, oh please, let's include enumerate = [minBound .. maxBound] as an export.

@int-index
Copy link

Why the name enumerate? I expected enumerate = zip [0..] because there is a similar function in Python.

@Kleidukos
Copy link
Member

Ah indeed that would be not too great to have a conflict on this. I've seen universe in Relude. That would be a reasonable alternative?

@tomjaguarpaw
Copy link
Member

I think discussion about a new function needs a new proposal. Can we please avoid scope creep in this discussion?

@bgamari
Copy link
Author

bgamari commented Sep 25, 2023

Given there is some disagreement on the details here, I have dropped enumerate from the proposal. As I don't have a particular interest here, I will leave a proposal introducing it to someone else (but they should feel free to reference !11321).

@tomjaguarpaw
Copy link
Member

I'm confused. ghc-!0422 looks like it has already been merged.

@bgamari
Copy link
Author

bgamari commented Sep 25, 2023

@tomjaguarpaw , yes, this proposal arose out of a miscommunication in #146.

@tomjaguarpaw
Copy link
Member

Aha, I see. Thanks!

@ocharles
Copy link

Does Bounded make sense to be in Data.Enum? An alternative is to house that in Data.Bounded.

@bgamari
Copy link
Author

bgamari commented Sep 25, 2023

My initial thought was that Enum and Bounded tend to appear together (and indeed they are both defined in the GHC.Enum module) but yes, I agree that exposing them as separate modules makes some amount of sense. I have amended the proposal to do so.

@bgamari bgamari changed the title Introduce Data.Enum Introduce Data.Enum and Data.Bounded Sep 27, 2023
@Bodigrim
Copy link
Collaborator

Bodigrim commented Jan 9, 2024

Dear CLC members, let's vote on the proposal to provide canonical home for class Enum and class Bounded in Data.* land (namely, Data.Enum and Data.Bounded) as opposed to being exported only from GHC.Enum and Prelude. Status quo is unfortunate: if you do not want to import entire Prelude, you have to import GHC.Enum which has a flavour of internal module, prone to rapid changes. We discussed the issue earlier in #64 and #146.

@tomjaguarpaw @hasufell @mixphix @angerman @parsonsmatt @velveteer


+1 from me.

@velveteer
Copy link
Contributor

+1

4 similar comments
@hasufell
Copy link
Member

hasufell commented Jan 9, 2024

+1

@tomjaguarpaw
Copy link
Member

+1

@parsonsmatt
Copy link

+1

@mixphix
Copy link
Collaborator

mixphix commented Jan 9, 2024

+1

@Bodigrim
Copy link
Collaborator

Bodigrim commented Jan 9, 2024

Thanks all, that's enough votes to approve.

@bgamari please make sure that both MRs land into the same GHC release.

@Bodigrim Bodigrim closed this as completed Jan 9, 2024
@Bodigrim Bodigrim added the approved Approved by CLC vote label Jan 9, 2024
hubot pushed a commit to ghc/ghc that referenced this issue Feb 15, 2024
@bgamari
Copy link
Author

bgamari commented Feb 15, 2024

Implementation in !11347.

hubot pushed a commit to ghc/ghc that referenced this issue Feb 15, 2024
hubot pushed a commit to ghc/ghc that referenced this issue Feb 16, 2024
@Bodigrim Bodigrim added the awaits-merge Approved, but MR is still unmerged label Jun 20, 2024
@Bodigrim
Copy link
Collaborator

@bgamari I'm not sure what's happened here. The proposal we approved meant to introduce Data.Bounded for class Bounded and Data.Enum for class Enum. Yet in base-4.20 I observe Data.Enum with both type classes, but no Data.Bounded at all. There is neither changelog nor @since pragma. Even more confusingly, the MR which was meant to implement the proposal remains unmerged: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/11347

I'm not sure what to do, the genie is out of the bottle. We cannot reasonably remove class Bounded from Data.Enum now. Does it still make sense to introduce Data.Bounded?..

hubot pushed a commit to ghc/ghc that referenced this issue Aug 27, 2024
hubot pushed a commit to ghc/ghc that referenced this issue Oct 1, 2024
As proposed in [CLC#208] but unfortunately `Data.Enum` was already
incorrectly introduced in the `ghc-internal` refactor.

[CLC#208]: haskell/core-libraries-committee#208
hubot pushed a commit to ghc/ghc that referenced this issue Oct 1, 2024
This begins the process of bringing us into compliance with
[CLC#208].

[CLC#208]: haskell/core-libraries-committee#208
hubot pushed a commit to ghc/ghc that referenced this issue Oct 1, 2024
As proposed in [CLC#208] but unfortunately `Data.Enum` was already
incorrectly introduced in the `ghc-internal` refactor.

[CLC#208]: haskell/core-libraries-committee#208
hubot pushed a commit to ghc/ghc that referenced this issue Oct 1, 2024
This begins the process of bringing us into compliance with
[CLC#208].

[CLC#208]: haskell/core-libraries-committee#208
hubot pushed a commit to ghc/ghc that referenced this issue Oct 1, 2024
As proposed in [CLC#208] but unfortunately `Data.Enum` was already
incorrectly introduced in the `ghc-internal` refactor.

[CLC#208]: haskell/core-libraries-committee#208
hubot pushed a commit to ghc/ghc that referenced this issue Oct 1, 2024
This begins the process of bringing us into compliance with
[CLC#208].

[CLC#208]: haskell/core-libraries-committee#208
hubot pushed a commit to ghc/ghc that referenced this issue Oct 3, 2024
As proposed in [CLC#208] but unfortunately `Data.Enum` was already
incorrectly introduced in the `ghc-internal` refactor.

[CLC#208]: haskell/core-libraries-committee#208
hubot pushed a commit to ghc/ghc that referenced this issue Oct 3, 2024
This begins the process of bringing us into compliance with
[CLC#208].

[CLC#208]: haskell/core-libraries-committee#208
hubot pushed a commit to ghc/ghc that referenced this issue Oct 10, 2024
As proposed in [CLC#208] but unfortunately `Data.Enum` was already
incorrectly introduced in the `ghc-internal` refactor.

[CLC#208]: haskell/core-libraries-committee#208
hubot pushed a commit to ghc/ghc that referenced this issue Oct 10, 2024
This begins the process of bringing us into compliance with
[CLC#208].

[CLC#208]: haskell/core-libraries-committee#208
hubot pushed a commit to ghc/ghc that referenced this issue Nov 15, 2024
As proposed in [CLC#208] but unfortunately `Data.Enum` was already
incorrectly introduced in the `ghc-internal` refactor.

[CLC#208]: haskell/core-libraries-committee#208
hubot pushed a commit to ghc/ghc that referenced this issue Nov 15, 2024
This begins the process of bringing us into compliance with
[CLC#208].

[CLC#208]: haskell/core-libraries-committee#208
hubot pushed a commit to ghc/ghc that referenced this issue Dec 5, 2024
As proposed in [CLC#208] but unfortunately `Data.Enum` was already
incorrectly introduced in the `ghc-internal` refactor.

[CLC#208]: haskell/core-libraries-committee#208
hubot pushed a commit to ghc/ghc that referenced this issue Dec 5, 2024
This begins the process of bringing us into compliance with
[CLC#208].

[CLC#208]: haskell/core-libraries-committee#208
hubot pushed a commit to ghc/ghc that referenced this issue Dec 6, 2024
As proposed in [CLC#208] but unfortunately `Data.Enum` was already
incorrectly introduced in the `ghc-internal` refactor.

[CLC#208]: haskell/core-libraries-committee#208
hubot pushed a commit to ghc/ghc that referenced this issue Dec 6, 2024
This begins the process of bringing us into compliance with
[CLC#208].

[CLC#208]: haskell/core-libraries-committee#208
hubot pushed a commit to ghc/ghc that referenced this issue Dec 6, 2024
As proposed in [CLC#208] but unfortunately `Data.Enum` was already
incorrectly introduced in the `ghc-internal` refactor.

[CLC#208]: haskell/core-libraries-committee#208
hubot pushed a commit to ghc/ghc that referenced this issue Dec 6, 2024
This begins the process of bringing us into compliance with
[CLC#208].

[CLC#208]: haskell/core-libraries-committee#208
hubot pushed a commit to ghc/ghc that referenced this issue Dec 14, 2024
As proposed in [CLC#208] but unfortunately `Data.Enum` was already
incorrectly introduced in the `ghc-internal` refactor.

[CLC#208]: haskell/core-libraries-committee#208

(cherry picked from commit 56b9f48)
hubot pushed a commit to ghc/ghc that referenced this issue Dec 14, 2024
This begins the process of bringing us into compliance with
[CLC#208].

[CLC#208]: haskell/core-libraries-committee#208

(cherry picked from commit 336d392)
@Bodigrim Bodigrim added base-4.20 Implemented in base-4.20 (GHC 9.10) base-4.21 Implemented in base-4.21 (GHC 9.12) and removed awaits-merge Approved, but MR is still unmerged labels Dec 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Approved by CLC vote base-4.20 Implemented in base-4.20 (GHC 9.10) base-4.21 Implemented in base-4.21 (GHC 9.12)
Projects
None yet
Development

No branches or pull requests

10 participants