Learn to Code ยท zero-dependency ยท MIT

larzfsm

Finite state machines.

So much of an app is really a state machine - an order goes draft to shipped, a document draft to published. Modelling that as ad-hoc flags gets tangled. larzfsm lets you declare the states and allowed transitions, then fire events - so illegal moves are impossible and the logic is obvious.

larzscript pkg install fsm
View on GitHub →Learn the stack

What you get

Try it

import "fsm" as fsm
let m = fsm.new("draft")
fsm.transition(m, "submit", "draft", "review")
fsm.transition(m, "approve", "review", "published")
fsm.fire(m, "submit")
print(fsm.state(m))
print(fsm.can(m, "approve"))
Output
review
true

Why it's in the Larz Stack

larzfsm is a real Larzscript package (larzscript pkg install fsm) - money-native, zero dependencies, the same language as the rest of the estate, not a separate Python runtime. It composes with the rest of the Larz Stack and the Larz framework.