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

Test passing state and trigger as generic types #35

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft

Conversation

qmuntal
Copy link
Owner

@qmuntal qmuntal commented Mar 18, 2022

This PR is just to view which are the changes required to adopt Go 1.18 type parameters. I'm still not sure if it is worth making State and Trigger generic compared to the overhead of having type parameters polluting almost all internal functions.

@suhlig
Copy link

suhlig commented Jul 19, 2024

I made a new attempt to make State and Trigger generic based on the latest master branch (see master...suhlig:qmuntal-stateless:generic). Tests are passing, so I believe it is ready to be merged.

While I agree that the benefit is not huge, generic type parameters improve one important thing: As I am hiding the state machine behind my project's API, generic type parameters allow me to have State and Trigger be a type of my domain, so that my API does not leak stateful.State to its users.

I was also briefly thinking about the parameters to triggers and guard functions. I believe generics would be much more helpful to define the type and arity of parameters, but I wouldn't know how to achieve that without an explosion of type parameters (basically one for each distinct trigger + guard parameter).

Overall, stateless as been a pleasure to work with. Keep up the good work!

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

Successfully merging this pull request may close these issues.

2 participants