qmuntal / stateless

Go library for creating finite state machines
BSD 2-Clause "Simplified" License
898 stars 47 forks source link

Use generics for State and Trigger #34

Open soypat opened 2 years ago

soypat commented 2 years ago

Go 1.18 official release brings Generics to the table!

qmuntal commented 2 years ago

I've been playing with type parameters since the beginning, but I'm still not sure if they are a good addition to this library.

Anyway, you can try them by pointing to typeparams branch and check the diffs at #35.

If you do so, please report back with your experience!

soypat commented 2 years ago

I ended up coding a state machine implementation from scratch with a generic input argument. See https://github.com/soypat/go-maquina.

Wondering if maybe there's room for a related projects section in the readme to point users to this smaller state machine implementation?

husam-e commented 4 months ago

@qmuntal adding generic support would be quite valuable. Are you still open to contributing this to the lib? I'm exploring options for statechart libraries and type safety for states and triggers would be a meaningful benefit.