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

RFC: replace List.enum and List.enumFrom with zipWithIndex #6709

Open
kim-em opened this issue Jan 20, 2025 · 2 comments
Open

RFC: replace List.enum and List.enumFrom with zipWithIndex #6709

kim-em opened this issue Jan 20, 2025 · 2 comments
Labels
RFC Request for comments

Comments

@kim-em
Copy link
Collaborator

kim-em commented Jan 20, 2025

Currently we have List.enum : List α → List (Nat × α), List.enumFrom : Nat → List α → List (Nat × α), and Array.zipWithIndex : Array α → Array (α × Nat).

My current intentions are to:

  • rename List.enum to List.zipWithIndex
  • swap the pair order for the List functions
  • give both List and Array's zipWithIndex a default from : Nat := 0 argument that subsumes the functionality of enumFrom, and remove List.enumFrom.
@kim-em kim-em added the RFC Request for comments label Jan 20, 2025
@nomeata
Copy link
Collaborator

nomeata commented Jan 20, 2025

Not sure. I (as a Haskell user) expect the zipWith family to take a higher order function, and the zip family to return tuples. By that (IMHO useful convention) I could imagine renaming enum to zipIndex. But I'd be surprised if zipWithIndex would not be what it is right now.

I could imagine dropping enum if you want to simplify the API, or making it simp directly to zipWithIndex and the tuple constructor.

@nomeata
Copy link
Collaborator

nomeata commented Jan 20, 2025

Ah, but maybe worth cleaning up whether its called …Index or …Idx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFC Request for comments
Projects
None yet
Development

No branches or pull requests

2 participants