automata

CI Gitleaks Trivy OSV-Scanner Hex Hex Docs Hex Downloads License OpenSSF Scorecard

automata provides state transitions, cron and recurrence schedules, and retry decisions for Gleam. It compares filesystem snapshots, reads and writes iCalendar, and represents events with typed bodies and metadata. The APIs run on Erlang and JavaScript. Your application supplies the clock, executes scheduled work, reads files, and waits between retries.

Installation

gleam add automata

Usage

This automaton changes between two states for each input and accepts a sequence that ends in the active state:

import automata
import gleam/bool
import gleam/io

pub fn main() {
  let toggle = automata.Automaton(
    initial_state: False,
    transition: fn(state, _) { !state },
    accepting: fn(state) { state },
  )

  automata.accepts(toggle, [Nil, Nil, Nil])
  |> bool.to_string
  |> io.println
  // True
}

Reference

AreaOperations
Finite automataRun transitions and test acceptance using your own state and input types.
CronParse five-field UNIX expressions or construct validated field selectors.
Recurrence rulesParse RRULEs with seven frequencies, intervals, count or until limits, and supported BY filters.
SchedulesFind occurrences from cron, RRULE, fixed intervals, or one-shot schedules using civil dates and explicit boundaries.
EventsConstruct events with custom bodies, sources, correlation, causation, and trace metadata. Filter them with ordinary predicates.
Filesystem changesCompare snapshots for Create, Write, Remove, Rename, and Chmod operations. File identities support rename detection.
iCalendarRead calendar documents containing events, tasks, journals, free/busy periods, timezones, alarms, and unknown components.
Retry decisionsChoose the next action using fixed, exponential, or capped delays, optional jitter, and a reproducible seed. Attempt limits include the initial attempt.

Schedule dates are civil times at whole-second precision without timezone conversion. Search returns an error if it reaches its work limit or exceeds the target’s exact numeric range. The RRULE scheduler supports BYDAY, BYMONTH, BYMONTHDAY, BYHOUR, BYMINUTE, and Monday week starts. See the full API reference for input limits, validation errors, and iCalendar property preservation.

Development

See CONTRIBUTING.md for setup, tests, and release verification. Report problems in GitHub Issues. Release history is in CHANGELOG.md.

License

MIT.

✨ Search Document