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

Saturn.Queue.push interface #149

Open
Vincent-lau opened this issue Sep 6, 2024 · 1 comment
Open

Saturn.Queue.push interface #149

Vincent-lau opened this issue Sep 6, 2024 · 1 comment

Comments

@Vincent-lau
Copy link

Vincent-lau commented Sep 6, 2024

Hi,

I saw that the type signature for Saturn.Queue.push is 'a Saturn.Queue.t -> 'a -> unit while the queue in standard library has this the other way round val push : 'a -> 'a t -> unit, as i takes an element first, and then a queue, while in Saturn we take the queue first. I am wondering if there is any reason why this is done in a different way?

@lyrm
Copy link
Collaborator

lyrm commented Nov 28, 2024

Sorry for the delayed response!

We aim to maintain a consistent convention across all Saturn data structures. In the standard library, hash table functions always take the hash table as the first argument, whereas many other data structures (if not all), like Queue, take it as the last argument.

After some discussion, we decided that consistently placing the t type as the first argument is better. This reduces the risk of accidentally misplacing this argument, which can lead to confusing type errors.

The main downsides are that this approach doesn’t match the standard library API and prevents the use of chaining with |>. However, we believe that these drawbacks are outweighed by the benefits of having a consistent and less error-prone convention across Saturn’s data structures.

What do you think ?

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

No branches or pull requests

2 participants