A Clojure/ClojureScript library for building and using finite-state automata through functional composition.
Automat is a library for creating and using finite-state automata in Clojure and ClojureScript through functional composition. It solves the problem of defining complex state machines without a custom DSL, offering high performance and seamless integration with Clojure's functional paradigms.
Clojure and ClojureScript developers who need to implement finite-state machines for tasks like parsing, stream processing, or behavioral tracking.
Developers choose Automat for its blend of Ragel-like power with Clojure's composability, enabling fast, declarative automata that are easy to extend and visualize.
better automata through combinators
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Allows building automata using pure functions and combinators like `or`, `and`, `*`, making it declarative and easy to extend, as shown in the README examples with interposed patterns.
Compiled automata process 100 million elements in 500ms with mean transition times of 5ns, optimized for speed in high-throughput use cases.
The `$` operator enables attaching reducer functions for pattern-matching reduction, useful for accumulating state over input streams, like tracking user behavior in e-commerce flows.
Works in both Clojure and ClojureScript, with macros for precompilation in Clojure to improve startup times in ClojureScript applications.
Provides `automat.viz/view` to visualize automata states and transitions in Clojure, aiding in debugging and understanding complex FSMs.
Using the `$` operator for reduction can impact performance, as the README notes it's better to use `:start-index` and `:stream-index` for bulk processing in high-throughput cases.
Visualization via `automat.viz/view` is only available in Clojure, not in ClojureScript, reducing debugging capabilities in browser environments.
Requires familiarity with functional programming and state machine concepts, making it less accessible for developers new to these paradigms or Clojure's macro system.
Tied to the Clojure ecosystem, so it doesn't integrate with non-Clojure tools or libraries, which can be a constraint in polyglot projects.