--- layout: home title: Forma for email automation description: Email and marketing automation rules in a typed Lisp. A small prelude defines lanes, decisions, and predicates; a TypeScript-engine prototype checks each rule and generates Effect TypeScript before anything sends. sidebar: false aside: false pageClass: forma-index forma-email ---

Forma for email automation · pre-alpha prototype

Email automation you can review before it sends.

Who gets an email, when, and how fast. Write a campaign rule as a small Lisp form. Forma checks every lane, every decision, and every delivery failure, then generates plain Effect TypeScript for your sender. The whole vocabulary is one short prelude, shown in full below.

warmup.lispchecked by the prototype
<<< @/snippets/email/rule.lisp{lisp preludes=email}

Prelude-defined vocabulary · TypeScript engine only · current limits

01 The pitch

A campaign is a program. Check it like one.

Marketing automation is mostly rules: hold this email if another one is about to land, skip people who already bought, send Gmail addresses on a slower lane so the domain keeps trusting you. Those rules usually live in a visual builder, a YAML file, and a throttling script. Nothing checks them together, so mistakes show up in someone's inbox. Forma treats the rule as source code with a small, closed vocabulary: - **Lanes are a type.** A rule's lanes become a union of names. Sending on `"gmial"` is a compile error at that clause, not a silent fallback onto the bulk lane. - **Every contact gets exactly one decision.** Clauses apply top to bottom, and the rule must end with a decision for everyone else: `send`, `defer`, or `skip`. - **Rules are pure.** A rule cannot call your mail provider, so it can be evaluated over a whole audience without sending anything. - **Delivery failures are part of the contract.** If the provider can fail with `Bounced` or `RateLimited`, the code that sends must turn each failure into a decision. - **The output is ordinary Effect.** Schemas, a tagged decision union, and an `Effect` with no escaped failures. No Forma runtime ships with it. None of this is built into the compiler. The words a rule can use (`send`, `tag?`, `due?`, and the rest) are typed definitions in one prelude file. Change the prelude and the language changes with it.

The prelude

preludes/email.lisp

Prototype · TypeScript engine

The contact

EmailContact is what a rule can see about one recipient. Your host computes its fields, including :due-in, the hours until each journey's next scheduled email.

The decisions

EmailDecision closes the set of answers. send, defer, and skip are ordinary typed functions that build them.

The predicates

tag?, domain?, and due? are ordinary functions too. They take the contact first; a rule leaves it out.

The form

rule declares the syntax and an emit hook for the exported rule record. The linker adds the rule's lanes as EmailLane, passes the contact to predicates, and reads 6h or 2d as hours.

email.lispbundled prelude, verbatim
<<< @/../preludes/email.lisp{lisp fragment}

03 In action

Break the rule. Watch it refuse to send.

This workbench runs the email prelude and the Effect checker in your browser. The rule is followed by ordinary Effect code: a Mailer service and a run-warmup operation that delivers whatever the rule decides. Introduce error misspells the Gmail lane. Open Effect TypeScript to see fresh generated code.

04 What it catches

Four mistakes that would have sent the wrong email.

Each diagnostic below is real compiler output for a one-line edit to the program above, located in the author's source.

a lane typoreal diagnostic
<<< @/snippets/email/lane-typo.txt
the fallback send removedreal diagnostic
<<< @/snippets/email/fallthrough.txt
bounce recovery removedreal diagnostic
<<< @/snippets/email/unhandled-bounce.txt
skipped contacts ignoredreal diagnostic
<<< @/snippets/email/missing-arm.txt

05 The output

Plain Effect TypeScript.

This is the complete generated module for the program above, checked against effect@4.1.1. The conformance case compares it with a golden, typechecks it under strict settings, and runs a harness against recording, rate-limited, and bouncing mailers.

Schema-backed contacts

EmailContact, EmailLane, and EmailDecision are Effect schemas, so a host can decode contacts from a CRM export before a rule sees them.

A rule record

LaunchWarmup3 exports the rule's name, its decide function, and perHour for each lane. A scheduler reads rates from it.

A provider service

Mailer is a Context.Service. You implement it for your provider and provide the layer when you run runWarmup.

No escaped failures

runWarmup has type Effect<EmailDecision, never, Mailer>. Every declared provider failure has already become a decision.

warmup.tsactual generator output
<<< @/snippets/email/warmup.ts

06 Limits

What you give up, and what isn't there.

This is a small prototype on a pre-alpha language. The working part is the checker; most of an email platform is outside it.

Trade-offs

  • Two languages. Rules are Lisp; provider adapters, audience loading, and scheduling are TypeScript. Debugging follows generated code because source maps are absent.
  • A fixed contact. Rules see the prelude's EmailContact. Adding a field or predicate means editing the prelude.
  • No visual builder. Marketers who work in a drag-and-drop journey tool would need one built over this; none exists.

Missing today

  • Scope. One rule per source. No module linking, CLI command, or language-server support for these forms.
  • A runtime. Forma checks that every lane has a rate. It does not schedule, enforce rates, retry later, deduplicate sends, or wake deferred contacts.
  • The rest of email. No templates, audience queries, consent and unsubscribe handling, provider integrations, or deliverability tooling.

07 Next

Run the campaign before it sends.

Three proposed RFCs would turn checked rules into rehearsed ones. None of them is implemented.

Rule tests

Tests in Forma would let a rule carry its own examples: a customer is skipped, a new signup is deferred, a Gmail address takes the Gmail lane.

Dry runs

Checked evaluation pauses each host call with its source span, so a dry run could answer every delivery with "recorded, not sent."

Replay

Host-call journals would record a real send, replay a changed rule against it, and report the first contact who would now get a different email.

Open questions

Should suppression be a separate, always-checked clause rather than first-match? Where should journey timing and multi-email sequences live? Should templates be checked against the contact schema too?

08 Fit

When to try it.

Worth trying

  • Engineers who already own their email sending in TypeScript or Effect.
  • Writing audience and lane logic as checked rules, then calling the generated module from your own scheduler.
  • Exploring what a reviewable campaign language should look like before building one.

Not yet

  • Replacing a marketing automation platform or a journey builder.
  • Anything that needs scheduling, rate enforcement, consent tracking, or templates from Forma.
  • Teams that need stable syntax, editor tooling, or a compatibility promise.

Read the prelude, then try to break a rule.

The prelude is the language. The conformance case shows the generated module and the mailers that exercise it.