Aexol Language
DocsAexol LanguageWorkflows & Recipes
Aexol workflows define state machines with transitions. Plus ready-to-use recipes for common patterns.
Workflows & Recipes
Aexol workflows define state machines with transitions, making it easy to model business processes, application flows, and complex state management.
Basic Syntax
A workflow consists of states and transitions between them:
workflow OrderFlow {
initial: pending
pending -> processing
processing -> shipped
shipped -> delivered
}
✨ Edit in StudioInitial State
Use initial to explicitly set the starting state. If omitted, the first state listed becomes the initial state:
workflow TaskFlow {
initial: todo
todo -> in_progress
in_progress -> done
done -> archived
}
✨ Edit in StudioTransition Conditions
Add when clauses to make transitions conditional:
workflow OrderFlow {
initial: pending
pending -> processing when payment_confirmed
pending -> cancelled when timeout
processing -> shipped when items_packed
}
✨ Edit in StudioMultiple Transitions and Bidirectional Flows
States can have multiple outgoing transitions, and flows can move in both directions:
workflow DocumentFlow {
initial: draft
draft -> review
review -> draft // Can return to draft
review -> approved
approved -> published
published -> archived
archived -> draft // Can revive from archive
}
✨ Edit in StudioWorkflows with Types
Combine workflows with type definitions for complete business logic:
enum OrderStatus {
pending
processing
shipped
delivered
cancelled
}
type Order {
id: string
customerId: string
status: OrderStatus
items: OrderItem[]
total: number
}
workflow OrderFlow {
initial: pending
pending -> processing
pending -> cancelled
processing -> shipped
processing -> cancelled
shipped -> delivered
}
✨ Edit in StudioCode Generation
Aexol generates type-safe state machine classes from your workflow definitions in TypeScript, Python, Rust, Go, and JavaScript. Each generated class includes:
- An enum with all states
canTransitionTo(state)— check if a transition is validtransitionTo(state)— execute a transitiongetCurrentState()— read current state- Automatic initial state from your
initialdeclaration
Use Studio to generate code from any workflow.
Recipes
Ready-to-use patterns for common scenarios. Copy and adapt these to jump-start your workflow definitions.
Todo App
type Task {
id: string
title: string
description: string
status: TaskStatus
assigneeId: string
}
enum TaskStatus {
todo
in_progress
done
}
workflow TaskFlow {
initial: todo
todo -> in_progress when started
in_progress -> done when completed
in_progress -> todo when reverted
}
visitor TaskManager {
"create tasks"
"view tasks"
"edit tasks"
"assign tasks"
}
✨ Edit in StudioE-Commerce Order Flow
type Order {
id: string
customerId: string
items: OrderItem[]
total: number
status: OrderStatus
}
enum OrderStatus {
pending
payment_received
processing
shipped
delivered
cancelled
}
workflow OrderProcessing {
initial: pending
pending -> payment_received when payment_confirmed
payment_received -> processing
processing -> shipped when items_packed
shipped -> delivered when customer_confirms
pending -> cancelled when timeout
payment_received -> cancelled when refund_requested
}
✨ Edit in StudioDocument Approval
type Document {
id: string
title: string
content: string
authorId: string
status: DocumentStatus
reviewers: string[]
}
enum DocumentStatus {
draft
pending_review
approved
rejected
published
}
workflow DocumentApproval {
initial: draft
draft -> pending_review when submitted
pending_review -> approved when all_reviewers_approve
pending_review -> rejected when reviewer_rejects
rejected -> draft when author_revises
approved -> published when author_publishes
}
✨ Edit in StudioSupport Ticket System
type Ticket {
id: string
customerId: string
subject: string
description: string
priority: Priority
status: TicketStatus
assignedTo: string
}
enum Priority { low medium high urgent }
enum TicketStatus {
open
assigned
in_progress
waiting_customer
resolved
closed
}
workflow TicketLifecycle {
initial: open
open -> assigned when agent_assigned
assigned -> in_progress when agent_starts
in_progress -> waiting_customer when info_needed
waiting_customer -> in_progress when customer_responds
in_progress -> resolved when issue_fixed
resolved -> closed when customer_confirms
resolved -> in_progress when customer_reopens
}
✨ Edit in StudioUser Onboarding
type UserAccount {
id: string
email: string
name: string
status: OnboardingStatus
completedSteps: string[]
}
enum OnboardingStatus {
invited
email_verified
profile_created
preferences_set
tutorial_completed
active
}
workflow OnboardingFlow {
initial: invited
invited -> email_verified when email_confirmed
email_verified -> profile_created when profile_saved
profile_created -> preferences_set when preferences_saved
preferences_set -> tutorial_completed when tutorial_finished
tutorial_completed -> active when account_activated
email_verified -> invited when email_expired
}
visitor NewUser {
"verify email"
"create profile"
"set preferences"
"complete tutorial"
}
✨ Edit in StudioPayment Processing
type Payment {
id: string
orderId: string
amount: number
currency: string
status: PaymentStatus
}
enum PaymentStatus {
pending
processing
succeeded
failed
refunded
disputed
}
workflow PaymentFlow {
initial: pending
pending -> processing when payment_submitted
processing -> succeeded when payment_confirmed
processing -> failed when payment_declined
failed -> pending when retry_allowed
succeeded -> refunded when refund_issued
succeeded -> disputed when customer_disputes
}
✨ Edit in StudioInventory Management
type InventoryItem {
id: string
sku: string
name: string
quantity: number
status: InventoryStatus
warehouseId: string
}
enum InventoryStatus {
in_stock
low_stock
out_of_stock
reserved
damaged
returned
}
workflow InventoryFlow {
initial: in_stock
in_stock -> low_stock when quantity_below_threshold
low_stock -> out_of_stock when quantity_zero
low_stock -> in_stock when restocked
out_of_stock -> in_stock when restocked
in_stock -> reserved when order_placed
reserved -> in_stock when order_cancelled
reserved -> low_stock when order_shipped
in_stock -> damaged when damage_reported
damaged -> returned when return_authorized
}
agent InventoryBot {
"reserve stock"
"release stock"
"update stock levels"
"alert low stock"
}
✨ Edit in StudioAppointment Booking
type Appointment {
id: string
customerId: string
serviceId: string
dateTime: datetime
status: AppointmentStatus
notes: string
}
enum AppointmentStatus {
requested
confirmed
rescheduled
in_progress
completed
cancelled
no_show
}
workflow AppointmentFlow {
initial: requested
requested -> confirmed when provider_accepts
requested -> cancelled when customer_cancels
confirmed -> rescheduled when time_changed
confirmed -> in_progress when appointment_starts
confirmed -> cancelled when customer_cancels
confirmed -> no_show when customer_missed
in_progress -> completed when service_finished
no_show -> requested when customer_reschedules
}
visitor Customer {
"request appointment"
"view appointments"
"cancel appointment"
"reschedule appointment"
}
✨ Edit in StudioCourse Enrollment
type Enrollment {
id: string
studentId: string
courseId: string
status: EnrollmentStatus
progress: number
grade: string
}
enum EnrollmentStatus {
pending
enrolled
in_progress
completed
failed
withdrawn
}
workflow EnrollmentFlow {
initial: pending
pending -> enrolled when payment_confirmed
pending -> withdrawn when student_cancels
enrolled -> in_progress when course_started
in_progress -> completed when all_modules_finished_and_passing
in_progress -> failed when final_grade_below_threshold
in_progress -> withdrawn when student_withdraws
failed -> enrolled when student_retakes
}
agent EnrollmentBot {
"process enrollment"
"track progress"
"send reminders"
"issue certificates"
}
✨ Edit in StudioCI/CD Pipeline
type Build {
id: string
commitHash: string
branch: string
status: BuildStatus
logs: string
}
enum BuildStatus {
queued
building
testing
deploying
succeeded
failed
cancelled
}
workflow CICDPipeline {
initial: queued
queued -> building when runner_available
building -> testing when build_succeeds
building -> failed when build_fails
testing -> deploying when tests_pass
testing -> failed when tests_fail
deploying -> succeeded when deploy_succeeds
deploying -> failed when deploy_fails
queued -> cancelled when user_cancels
}
✨ Edit in StudioRecipe Comparison
| Recipe | Complexity | States | Transitions | Best For |
|---|---|---|---|---|
| Todo App | Low | 3 | 3 | Simple task tracking |
| User Onboarding | Medium | 6 | 5 | Multi-step registration flows |
| CI/CD Pipeline | Medium | 7 | 8 | DevOps automation |
| Appointment Booking | Medium | 7 | 8 | Service scheduling |
| Course Enrollment | Medium | 6 | 7 | Learning management systems |
| Payment Processing | Medium | 6 | 6 | Financial transactions |
| Document Approval | Medium | 5 | 5 | Review and publishing flows |
| Support Ticket System | Medium-High | 6 | 7 | Customer service platforms |
| E-Commerce Order Flow | Medium-High | 6 | 6 | Online retail |
| Inventory Management | High | 6 | 8 | Warehouse and supply chain |
Best Practices
- Keep states minimal — each state should represent a distinct, meaningful stage; don't model transient moments
- Name states clearly — use
awaiting_paymentnotstate3; names are your documentation - Model conditions explicitly — every transition should have a clear
whencondition that reflects a real-world trigger - Separate concerns — split large workflows into smaller, focused ones rather than cramming everything into a single flow
- Align workflows with enums — when a type has a status field, its enum values should mirror the workflow states
- Use agents for automation — let agents like
NotificationServiceorInventoryBotreact to transitions rather than embedding side effects in the workflow
Quick Start Tips
- Start by listing all the states your process goes through
- Draw the transitions on paper or a whiteboard first — it reveals gaps and dead ends
- Add
whenconditions to each transition to make the intent explicit - Create an enum that mirrors your states, then use it in a type
- Define visitors to model who can trigger which transitions
- Add agents for any automated side effects (notifications, stock updates, logging)
See Also
- Language Reference — Full workflow syntax and all language features
- Advanced Types — Arrays, circular references, and complex data structures
- Tutorial — Build a complete specification step by step