Documentation Menu · Forms, Structures & Types

Forms, Structures & Types

Complete syntax reference for Hector’s closed words, structural aggregates, composites, and dimensional quantities.

Reference entries for the closed words of Hector's syntax that shape rules, laws and examples. Each entry gives the meaning for someone who writes rules, then a small program that uses the word and holds.

after #

After a duration, the change happens when that much time has passed since the row entered its starting status. The change lands at the exact end of the duration, so an event due at that same instant is applied first. Use it for a timeout counted from the entry into a status, such as a place kept for ten minutes. A deadline counted from a fixed date is a when that compares now with the date instead, because it does not depend on when the row entered. Hector computes the instant of the change; the writer never writes a timer.

forms/after.hector
Verified Example
-- but: une place tenue 10 min, puis libérée sans action
Desk
lease = 10 min

Seat  label: Text
  status: Held | Free
  -> Held on Reserve by Desk
  Held -> Free after lease
  show status to Desk within 1 s

example delai
  s = Reserve(label: "A1")
  after 9 min
  see s is Held
  after 1 min
  see s is Free

and, or, not #

These three combine truth values in conditions, laws and definitions: and holds when both sides hold, or when one side holds, and not reverses a truth value. The logic has three values: an Unknown answer from the world is never taken as false, so a condition that waits for an answer stays open instead of failing. To test that a value is absent, write not any(...) on it, as the language sheet gives for none. A status test is negated with is not, the form the sheet gives as file is not Removed. The example combines two status tests and a comparison of an amount.

forms/and.hector
Verified Example
-- but: une commande est prête si elle est payée et non annulée ; elle attend sinon
Clerk
Order  amount: Money
  status: Open | Paid | Cancelled
  -> Open on Place by Clerk
  Open -> Paid on Pay by Clerk
  Open -> Cancelled on Cancel by Clerk
  ready = status is Paid and not status is Cancelled and amount > 0 EUR
  waiting = status is Open or status is Cancelled
  show ready, waiting to Clerk within 1 s

example deux commandes
  c = Place(amount: 20 EUR)
  d = Place(amount: 5 EUR)
  Pay(c)
  Cancel(d)
  see c.ready = true
  see c.waiting = false
  see d.ready = false
  see d.waiting = true

as #

as gives a name to the row being looked at inside an aggregate, so that a count over a sort can compare each row with the others. In a count over a sort, the name after as refers to each row in turn, while the subject's own fields keep their names. The row being counted is included, so in a group of two each member gets a count of two. In a show, the same word names the observer instead, and the condition can read the observer's fields through that name. The language sheet also uses as to name an element of a relation reached through another sort.

forms/as.hector
Verified Example
-- but: un employé compte ses collègues du même service, lui-même compris
Clerk
Staff  dept: Text
  peers = count(Staff as other where other.dept = dept)
  show peers to Clerk within 1 s
  -> on Join by Clerk

example equipes
  a = Join(dept: "Ventes")
  b = Join(dept: "Ventes")
  c = Join(dept: "Achats")
  see a.peers = 2
  see c.peers = 1

assume #

assume states a premise about the world that the program does not control, such as a bound on how old a value from an outside source may be. Hector watches the premise: while it holds, the values that depend on it are trusted; when it breaks, they are reopened instead of silently read. In the example the premise bounds the age of an answer given by a by field, so an older reading is no longer trusted. A value whose premise is broken reads as Unknown until a new answer arrives, and the example checks this after a wait. Write an assume only for a business bound; a speed or a size is measured, not stated. The form assume e else Name keeps the fact and names each row that breaks the premise, which this entry does not show.

forms/assume.hector
Verified Example
-- but: le niveau d'une cuve vient d'un capteur ; il ne vaut plus rien au-delà de 15 min
Clerk
Probe
Tank  level: Ratio by Probe
  -> on Watch by Clerk
  assume age(level) <= 15 min
  show level to Clerk within 1 s

example lecture recente puis périmée
  t = Watch
  t.level = 40 % by Probe
  after 10 min
  see t.level = 40 %
  after 10 min
  see t.level is Unknown

at #

at in an example moves the clock forward to the given instant; it never moves back. Everything due at that instant happens before the lines that follow are read. Use it with a time-triggered rule, such as a when that compares now with a date, to show the rule firing only after its limit. An at that goes back in time, before the line above it, is refused for its order. The clock moves only inside the example; it does not change the program.

forms/at.hector
Verified Example
-- but: un rendez-vous devient en retard quand l'heure est dépassée de 15 min
Clerk
Visit  slot: Instant
  status: Booked | Late
  -> Booked on Book by Clerk
  Booked -> Late when now > slot + 15 min
  show status to Clerk within 1 s

example retard
  v = Book(slot: 2026-11-10T09:00)
  at 2026-11-10T09:10
  see v is Booked
  at 2026-11-10T09:20
  see v is Late

by #

by names who decides: by Bank on a field means the bank answers it, so Hector treats the value as unknown until that answer comes. On an event, by names who may trigger it, either a role such as by Clerk or a field of the row, such as by payer, which is the person the row names. A set can also be named after by, as in by document.writers, and then any one of its members may act. An example may leave out by when the role is clear; a named person must be written after it. After a show, the same word orders the rows by increasing key, and top(n, … by e) keeps the n largest.

forms/by.hector
Verified Example
-- but: un paiement est décidé par la banque ; le client ne décide que de l'envoi
Bank
Customer  name: Text
Charge  payer: Customer, amount: Money
  status: Pending | Done | Refused
  card: Accepted | Declined by Bank on Give
  -> Pending on Give by payer
  Pending -> Done when card is Accepted
  Pending -> Refused when card is Declined
  show status, amount to Bank by amount within 1 s

example paiements
  ana = Customer(name: "Ana")
  bo = Customer(name: "Bo")
  p = Give(payer: ana, amount: 10 EUR)
  q = Give(payer: bo, amount: 4 EUR)
  p.card = Accepted by Bank
  q.card = Declined by Bank
  see p is Done
  see q is Refused

else, if #

a if c else b is an expression that gives a when c holds and b when it does not; it is never a statement, so it cannot assign anything. When c is absent, because an optional value is empty, the result is b; when c is unknown, because an answer has not come, the result is Unknown. Both branches give values of the same kind, so a discount on an amount stays an amount. Inside a match, else followed by an arrow covers every case that is not listed. The example gives a member a ten per cent discount and a guest the full price.

forms/else.hector
Verified Example
-- but: un membre paie 10 % de remise ; un invité paie le prix plein
Clerk
Basket  total: Money, tier: Member | Guest
  price = (total - total * 10 %) if tier is Member else total
  show price to Clerk within 1 s
  -> on Open by Clerk

example remise
  m = Open(total: 200 EUR, tier: Member)
  g = Open(total: 200 EUR, tier: Guest)
  see m.price = 180 EUR
  see g.price = 200 EUR

every #

every declares a clock or a periodic event: a clock with a period makes a tick at each period, and the rules of its block read that period as dt. A value written with next takes its new value on each tick, computed from the values as they were just before that tick. The clock is declared at column zero, once for the program, and the period may be a fraction of a second; a clock inside a block, with a phase per element, is in FICHE.md but this checker does not yet run it correctly. A periodic event may carry arguments, like any event. The example runs for three seconds and expects three ticks, because a tick due at the instant of the check has already happened.

forms/every.hector
Verified Example
-- but: un compteur qui avance d'un cran à chaque seconde
Operator
Tick every 1 s

Counter  turns: Count
  -> on Open by Operator
  start turns = 0
  next turns = turns + 1
  show turns to Operator within 1 s

example tours
  c = Open
  after 3 s
  see c.turns = 3

exact #

exact on a show asks for the value to be the same to the byte, with no rounding or tolerance, which is what replay and audit need. Without it, an observer that accepts a tolerance (written with +-) may receive a value rounded to that tolerance, and Hector may choose a cheaper form for it. It is written on the show line after the values and before to. The same run must then give the same bytes every time it is replayed. The example checks an exact balance: a hundred euros less thirty euros gives seventy.

forms/exact.hector
Verified Example
-- but: un solde montré à l'auditeur à l'octet près, sans arrondi
Auditor
Account  opening: Money
  balance = opening - sum(debits.amount)
  show balance exact to Auditor
  -> on Open by Auditor

Debit  account: Account, amount: Money
  law amount > 0 EUR
  -> on Post by Auditor

example solde exact
  a = Open(opening: 100 EUR)
  Post(account: a, amount: 30 EUR)
  see a.balance = 70 EUR

example #

An example in column zero is a worked case: it has a name in free text and lists its facts in order, one per line. It is a test as well as a usage example: if one of its see lines is false, the verdict is 1 and a counter-example is given. Write two to four examples per program, and give a value only when you have computed it by hand. The lines of an example say who exists, which events happen, how much time passes, and what must be true. The name may contain spaces and accents, so a case can be named in plain French.

forms/example.hector
Verified Example
-- but: un joueur marque des points ; son total est la somme de ses points
Operator
Player  name: Text
  points = sum(scores.amount)
  show name, points to Operator within 1 s
  -> on Join by Operator

Score  player: Player, amount: Count
  law amount >= 1
  -> on Award by Operator

example un joueur qui marque deux fois
  ana = Join(name: "Ana")
  Award(player: ana, amount: 4)
  Award(player: ana, amount: 2)
  see ana.points = 6

hidden #

hidden inside an example says that one observer must not receive a value; the example is false if the program would show that value to that observer. It checks the program's show lines and does not order anything to be hidden: the program must be written so that the observer does not get the value. The observer can be a role or a named person, as the example shows with one of its customers. Write it after the events that create the value, so that the check looks at what the observer would see. In the example the note of a case is shown to the clerk only, and the customer is checked not to receive it.

forms/hidden.hector
Verified Example
-- but: la note interne d'un dossier reste au conseiller ; le client ne voit que l'état
Clerk
Customer  name: Text
Case  customer: Customer, note: Text
  status: Open | Closed
  -> Open on File by Clerk
  Open -> Closed on Close by Clerk
  show note to Clerk within 1 s
  show status to customer within 1 s

example note interne cachée
  ana = Customer(name: "Ana")
  d = File(customer: ana, note: "à vérifier")
  see d.status is Open
  hidden d.note to ana

in #

in tests membership: a value is in a collection when it is one of its elements, or one of the keys of a map when that map is given through keys. It gives a truth value, so it can serve in a definition, a condition or a law, as well as in a show. Collections include sets of rows and the keys of a map, and the example uses the second of them. Use it for a lookup that asks yes or no, such as whether a product is listed; a value that is not listed gives false. The example sells one listed product and one that is not, and checks the answer of each.

forms/in.hector
Verified Example
-- but: une vente ne porte que sur un article du catalogue du magasin
Clerk
Shop  catalog: Map(Text, Money)
  -> on Open by Clerk

Sale  shop: Shop, item: Text
  listed = item in keys(shop.catalog)
  show listed to Clerk within 1 s
  -> on Sell by Clerk

example article du catalogue
  s = Open(catalog: ["pain": 2 EUR, "lait": 1 EUR])
  v = Sell(shop: s, item: "pain")
  w = Sell(shop: s, item: "vin")
  see v.listed = true
  see w.listed = false

is #

is tests the status, the answer or the case of a value: is Waiting holds only while the row has that status. is not negates the test, and is A | B holds when the status is one of several. The word reads the current status; it never sets one, which only events and transitions do. For an answer from the world, testing that the answer is still Unknown tells that no answer has arrived yet. Compare two fields with = rather than is, since is only tests a status, an answer or a case. The example follows one parcel through its three statuses.

forms/is.hector
Verified Example
-- but: un colis passe par trois statuts ; « is » lit le statut courant
Clerk
Parcel  weight: Mass
  status: Waiting | Shipped | Delivered
  -> Waiting on Receive by Clerk
  Waiting -> Shipped on Ship by Clerk
  Shipped -> Delivered on Deliver by Clerk
  show status to Clerk within 1 s

example un colis
  p = Receive(weight: 2 kg)
  see p is Waiting
  Ship(p)
  see p is Shipped | Delivered
  see p is not Delivered
  Deliver(p)
  see p is Delivered

law #

law states what must hold; a law inside a block holds for each row of that sort, and Hector derives from it the refusal of every event that would break it. In the example a room takes at most two reservations, so a third booking is refused and the count stays at two. A law that nothing can keep, such as one that depends on a time or on an answer of the world, is refuted; its repair is an assume that names the premise. A law under a function states a property of that function, proved once; this entry does not show that form. A law at column zero covers the whole world and may only name sorts, so a law about one sort is written under that sort.

forms/law.hector
Verified Example
-- but: une salle ne reçoit jamais plus de deux réservations
Clerk
Room  name: Text
  taken = count(reservations)
  law taken <= 2
  -> on Open by Clerk

Reservation  room: Room
  -> on Book by Clerk

example salle pleine
  r = Open(name: "Salle A")
  Book(room: r)
  Book(room: r)
  refused Book(room: r)
  see r.taken = 2

match #

match chooses a value by the case of a composed value: one case per indented line, with the case on the left and the value on the right. Several cases that share a value are written together with |, and a case may name the fields of its payload without the sort. A missing case with no else line covering it is refused as not exhaustive, so every case must be given or caught. The else line covers the cases not listed, and a later change that adds a case shows where it falls. The example gives each plan its limit, and the two paid plans share one value.

forms/match.hector
Verified Example
-- but: un forfait donne une limite de requêtes par minute
Clerk
Client  plan: Free | Pro | Team
  limit = match plan
    Free -> 10
    Pro | Team -> 600
  show limit to Clerk within 1 s
  -> on Subscribe by Clerk

example forfaits
  a = Subscribe(plan: Free)
  b = Subscribe(plan: Team)
  see a.limit = 10
  see b.limit = 600

minimizing, maximizing #

minimizing and maximizing give the direction of an optimum in the and in tie. With the, minimizing picks the row with the smallest key and maximizing picks the largest. Several keys are read in order, and a key without its own word follows the direction of the key before it. If no row qualifies, the result is absent; a where limits the candidates to the rows that pass it. In tie, the same word settles a race between simultaneous changes: the best key wins, then the identity. The example picks the nearest courier, whose distance is the smaller of the two.

forms/minimizing.hector
Verified Example
-- but: le coursier le plus proche prend la commande ; à distance égale, le mieux noté
Dispatcher
Courier  name: Text, pos: Point m, rating: Ratio
  -> on Join by Dispatcher

Order  pos: Point m
  courier = the Courier minimizing dist(Courier.pos, pos), maximizing Courier.rating
  show courier.name to Dispatcher within 1 s
  -> on Place by Dispatcher

example le plus proche
  ana = Join(name: "Ana", pos: (0, 0) m, rating: 90 %)
  bo = Join(name: "Bo", pos: (3, 4) m, rating: 50 %)
  o = Place(pos: (1, 1) m)
  see o.courier.name = "Ana"

Reference entries for the closed words of the language, in alphabetical order. Each entry gives the meaning for someone who writes rules, what it derives or refuses, and the example that checks it. A word that only exists inside an example, such as refused or see, is shown with a small world around it.

next #

next gives a field the value it takes at the next tick of its block's clock, or just after the event named by on. Inside a rule it always reads the state from before the change, so the new value is computed from the old one. Give the field a start value so that the first reading exists; use next for a counter or any value that changes with each event.

forms/next.hector
Verified Example
-- but: compter les essais de livraison rates
Clerk
Parcel  name: Text
  status: Waiting | Out | Delivered
  start attempts = 0
  next attempts = attempts + 1 on Fail
  -> Waiting on Register by Clerk
  Waiting -> Out on Depart by Clerk
  Out -> Waiting on Fail by Clerk
  Out -> Delivered on Deliver by Clerk
  show attempts to Clerk within 1 s
example deux echecs
  p = Register(name: "Colis")
  Depart(p)
  Fail(p)
  Depart(p)
  Fail(p)
  see p.attempts = 2

on #

On a transition, birth or update, on names the event that drives it: a user, a device or another service calls the event. A line such as Open -> Closed on Close by owner says which transition the event drives and who may call it. An event may carry parameters: a typed parameter brings a new value, a bare name takes a field that already exists. A call that no line accepts is refused, and the refusal lists the reasons.

After prefer, a byte bound or restrict adapt, on names the scope of the policy: a sort, an event, a corridor (A -> B between two events or two statuses, E -> from an event on, or the name of a path) or a qualified definition. Use Sort.definition for a definition; a bare local definition name can be predeclared as an event by the current reader. These policy lines give goals, bounds or permissions for realization; they do not add an event handler.

forms/on.hector
Verified Example
-- but: un ticket se ferme sur la demande de son client
Customer  name: Text
Ticket  owner: Customer
  status: Open | Closed
  -> Open on Place by owner
  Open -> Closed on Close by owner
  show status to owner within 1 s
example fermeture
  ana = Customer(name: "Ana")
  t = Place(owner: ana)
  Close(t)
  see t is Closed

path #

path name = A -> B names a corridor: what lies between two ends of the program, each an event or a status of any sort (Cart.Open -> Order.Paid joins two sorts). A chain A -> B -> C is one corridor, which holds what lies between each end and the next. The corridor holds the events, and the changes of no event (when, after), on every walk from the first end to the second, so the second end must follow the first. It also holds a birth of no event (-> A when c) into a status those walks go through, and the answers they wait on: a field asked on one of its events (by Who on E) that a transition on the way reads. The prefer and restrict lines indented under it are those lines on the name, and on name says the same anywhere else; a line written on A -> B for the same ends holds on the same corridor. The name is lowercase, of its own (no event, sort, definition or function bears it) and given once to a path.

forms/path.hector
Verified Example
-- but: de la commande payee a son envoi, un chemin qui porte un nom et son but
Clerk
Order
  status: Open | Paid | Shipped
  -> Open on Place by Clerk
  Open -> Paid on Pay by Clerk
  Paid -> Shipped on Ship by Clerk
  show status to Clerk within 1 s
path fulfilment = Paid -> Shipped
  prefer speed, memory
example envoi
  o = Place()
  Pay(o)
  Ship(o)
  see o is Shipped

per #

per groups or windows an aggregate: count(visits per day) counts the visits of each day on its own. Put it inside a law to cap a count per period, so the limit applies to each day rather than to the whole history. The example allows two entries a day and refuses a third one on the same day. Other periods, such as per hour or per 24 h, use the same form, and the unit belongs to the period.

forms/per.hector
Verified Example
-- but: au plus deux entrees par membre et par jour
Gate
Member  name: Text
  law count(visits per day) <= 2
Visit  member: Member
  -> on Enter by Gate
show count(Visit) to Gate within 1 s
example deux entrees par jour
  ana = Member(name: "Ana")
  Enter(member: ana)
  Enter(member: ana)
  refused Enter(member: ana)
  see count(Visit) = 2

personal #

personal is a field qualifier written after the type, alone or beside secret and in either order: the value is information about the row that holds it. It refuses nothing and changes nothing at run time: a personal value is shown, computed with and journaled as any other, unless it is also secret. Use it on a name, an address or a birth date, so the program says which data is about a person. A mark belongs to a field: a computed definition cannot write it, it is computed from what carries it.

forms/personal.hector
Verified Example
-- but: le nom d'un adherent est une donnee sur lui
Desk
Member  name: Text personal, visits: Count
  -> on Join by Desk
  next visits = visits + 1 on Visit by Desk
  greeting = name
  show greeting, visits to Desk within 1 s
example the card carries the name
  ana = Join(name: "Ana", visits: 0)
  Visit(ana)
  see ana.greeting = "Ana"
  see ana.visits = 1

hector describe <program> --privacy maps where personal data goes (--json for the same facts as data): each personal field and what a journal keeps of it; each member that holds personal data, computed from it through definitions, start and next lines, references and functions, or written from an event input that also fills it; the shows that read one, saying whether they go only to the row's own party; the requests that send one out; and the laws, conditions, deadlines and ties it decides. The map says where a value goes, not what someone can infer: a line it decides may change anything that line changes. What an outside party answers to a request is its own: mark the answered field if it is personal.

Executable CLI Run
verdict 0
hector describe forms/personal.hector --privacy

allow #

allow stale 5 s [on Sort] gives written observations a freshness window from their value's lexical scope. An observation can give its own within duration. When it reads several sorts, each read must permit a window and the shortest one applies. A guard or law still needs its value at the step.

stale #

stale is read after allow with a positive duration. It grants a freshness window to observations within the scope that supplies the value.

expect, rows #

expect rows 5000..15000 tells the search how many rows to try. In a sort block it applies to that sort, or name a sort with on. At the same place the ranges combine into an enclosing range, and the closest lexical place wins. A supplied search load keeps precedence. Expectations guide the trial population and leave program results unchanged.

prefer #

prefer latency asks for the response time of an entry. The current forms rank it with speed, and config reports that shared cost family. A bound can ask for a 99th-percentile time under a bound (prefer p99 <= 2 ms on Submit) or a memory budget (prefer memory <= 64 MB on Order): a budget that ranks the forms and never refuses one. It never changes the result of a rule: the value is the same with or without it. It only steers the realisation that Hector chooses, so it concerns speed, not the value. The example therefore checks the value alone, which an example can state by hand. One line may name several axes (prefer memory, speed): the first matters most. The scope is the place of the line or what on names, and the closest scope wins.

forms/prefer.hector
Verified Example
-- but: un total de ligne, avec un but de latence
Clerk
Line  qty: Count, price: Money
  total = qty * price
  -> on Add by Clerk
  show total to Clerk within 1 s
prefer p99 <= 2 ms on Add
prefer memory, speed
example total
  l = Add(qty: 3, price: 5 EUR)
  see l.total = 15 EUR

refused #

refused sits inside an example and names an event or an answer that must be turned down at that point. The example fails if the event is accepted; write the call with the same arguments as the event, and add by only to name a particular person. A refused call changes nothing, so the lines after it see the same state. Use it to show a rule at work, for instance an order that is already cancelled cannot be cancelled again.

forms/refused.hector
Verified Example
-- but: une commande annulee ne peut plus l'etre
Clerk
Order  total: Money
  status: Open | Cancelled
  -> Open on Place by Clerk
  Open -> Cancelled on Cancel by Clerk
  show status to Clerk within 1 s
example double annulation
  o = Place(total: 5 EUR)
  Cancel(o)
  refused Cancel(o)
  see o is Cancelled

rename #

rename changes a name without creating a new thing: the identity and the history of the rows stay the same. Write rename Old to New once the new name is declared in the program, as the example does for a sort that was called Ticket. Rows created under the old name remain the same rows, so their later changes keep their history. Use it for a name change only; a copy of the declaration with the old one deleted would start a new history.

forms/rename.hector
Verified Example
-- but: un ticket garde son identite quand son nom change : Ticket devient Case sans nouvel historique
Clerk
Case  title: Text
  status: Open | Closed
  -> Open on File by Clerk
  Open -> Closed on Close by Clerk
  show status to Clerk within 1 s
rename Ticket to Case
example renommage
  t = File(title: "Panne")
  Close(t)
  see t is Closed

restrict #

restrict is the one technical choice an author may write; it must be motivated in a note and audited. It narrows the realisations Hector may pick, here to run on the processor with device(Cpu), and it does not change the result. A contract about the deployment, such as residency(EU), is reported as not verified (verdict 3) until the deployment checks it, so it cannot make an example hold. restrict adapt none closes optional adaptation. restrict adapt reserve permits prepared forms. restrict adapt recipes also permits regeneration, whose availability is unestablished (verdict 3). Write a capacity, CPU share and reaction time together as in restrict adapt reserve, cpu <= 5 %, within 2 s. Each part inherits the closest scope. A CPU or reaction limit alone keeps the historical policy of Hector's runner and permits a delivered reserve. restrict memory <= 64 MB on Order and restrict p99 <= 2 ms on Submit bound the bytes the rows of a sort hold and the time of an event: a form past the memory bound is refused, and check measures both on this machine, or says verdict 3. A program-wide restrict memory <= n is also the linear-memory maximum of a Wasm module (the whole 64 KiB pages that fit n; build --wasm-memory-pages N may only tighten it): an engine refuses to grow past it, so build establishes that promise without a measure, and refuses a module that needs more.

forms/restrict.hector
Verified Example
-- but: un reglement reste calcule sur le processeur, seule restriction permise
Clerk
Invoice  total: Money
  status: Open | Paid
  -> Open on Issue by Clerk
  Open -> Paid on Pay by Clerk
  show status to Clerk within 1 s
restrict device(Cpu)  -- le calcul reste sur le processeur
restrict adapt cpu <= 5 %
example reglement
  f = Issue(total: 20 EUR)
  Pay(f)
  see f is Paid

secret #

secret is a field qualifier: the value of the field, and everything computed from it, stay with the row that bears it. They do not appear in a log or a trace, and they leave only to the party of that row (show balance to owner, or to Owner as viewer where owner = viewer) or as the argument of a by: a show to anyone else that reads the field, or a value computed from it, is refused (SECRET_REACHES_OBSERVER). Use it for a personal or financial value, such as a balance or a bank identifier. An example can check that an observer does not receive it with hidden.

forms/secret.hector
Verified Example
-- but: le solde d'un compte reste prive
Clerk
Owner  name: Text
Account  owner: Owner, balance: Money secret
  -> on Open by Clerk
  show balance to owner within 1 s
example solde cache
  ana = Owner(name: "Ana")
  a = Open(owner: ana, balance: 40 EUR)
  hidden a.balance to Clerk
  see a.balance = 40 EUR

see #

see belongs to an example: it states what must be true at that moment, a value or a status, for a named row. The example fails when the program does not give that value, so see is the check of the rule it follows. Write only values you have worked out yourself, with their unit: a bare number does not equal a length. The row comes first, then its field, as in the pallet example that checks the load of one pallet.

forms/see.hector
Verified Example
-- but: le poids total d'une palette
Clerk
Pallet  label: Text
  load = sum(crates.weight)
  -> on Build by Clerk
  show load to Clerk within 1 s
Crate  pallet: Pallet, weight: Mass
  -> on Pack by Clerk
example palette
  p = Build(label: "P1")
  Pack(pallet: p, weight: 2 kg)
  Pack(pallet: p, weight: 3 kg)
  see p.load = 5 kg

self #

self is the subject of the block seen as a value: inside a sort, it is the row whose rules are being read. Use it where a rule needs the row itself, for instance Ticket != self to leave the row out of a count. A bare field name already means the subject's field, so self is needed only when the row is the value wanted. The example counts the other tickets from each ticket, and checks two of the counts.

forms/self.hector
Verified Example
-- but: chaque billet compte les autres billets
Clerk
Ticket  name: Text
  others = count(Ticket where Ticket != self)
  -> on Open by Clerk
  show others to Clerk within 1 s
example trois billets
  a = Open(name: "A")
  b = Open(name: "B")
  c = Open(name: "C")
  see a.others = 2
  see c.others = 2

show #

show asks for an observation: it names what to show, who sees it, and optionally the freshness wanted, a tolerance (+- or ~) and an order. In show price ~ 1 % to Viewer, the percentage limits the error of each numeric component relative to the magnitude of its reference value; a zero reference stays exact, and an observation takes at most one tolerance. A value shown to nobody is neither computed nor kept, so each show line defines what the program must deliver. by sets the order of a list: by qty lists the rows from the smallest quantity upwards. The example checks two values behind shown rows; the observer receives the shown text itself.

forms/show.hector
Verified Example
-- but: la vue d'un rayon pour le magasinier
Clerk
Item  name: Text, qty: Count
  label = name
  -> on Add by Clerk
  show label, qty to Clerk by qty within 1 s
example rayon
  a = Add(name: "Vis", qty: 4)
  b = Add(name: "Clou", qty: 9)
  see a.qty = 4
  see b.label = "Clou"

start #

start gives a field the value it has at birth, or on entry into a sub-block status. A field declared in the header without start is supplied by the caller; with start, the program fixes the value. The example gives a drone a position and a zero speed at launch, and checks both. Use start for an initial value only: a value that changes later is written with next, never by a second start.

forms/start.hector
Verified Example
-- but: un drone nait au depot, sans vitesse
Clerk
Drone  name: Text
  start pos = (0, 0) m
  start speed = 0
  -> on Launch by Clerk
  show pos to Clerk within 1 s
example depart
  d = Launch(name: "D1")
  see d.pos = (0, 0) m
  see d.speed = 0

repeated, ignored #

repeated E when c and ignored E when c, written at the head of a line in a block, tell an event that changes nothing what its outcome is: repeated for an action already done, ignored for an action with no object. They are read before E, on the state before it and on its parameters; repeated comes first, then ignored, then the lines of E. When c holds nothing changes and E receives that outcome instead of a refusal. The example plays both outcomes and then a change that does apply.

forms/repeated.hector
Verified Example
Desk
Lamp  watts: Count
  state: Off | On
  Off -> On on Switch
  On -> Off on Cut
  repeated Switch when state is On
  ignored Cut when state is Off
  show state to Desk
example allumer puis couper
  l = Lamp(watts: 40)
  Switch(l)
  see l is On
  repeated Switch(l)
  Cut(l)
  ignored Cut(l)
  see l is Off

stays, while #

stays A while c is a law on the transitions: the row does not leave status A as long as the condition c holds. Use it while an answer is still unknown, such as a bank's reply: the reservation stays held while the payment is Unknown, and an event that would leave it is refused. When the answer arrives, the condition no longer holds and the usual transitions apply. The example asks the payment question, gives the answer, then checks the status it leads to.

forms/stays.hector
Verified Example
-- but: une reservation reste tenue tant que le paiement est incertain
Customer  name: Text
Booking  customer: Customer
  status: Held | Paid | Released
  payment: Accepted | Declined by Bank on Pay
  -> Held on Reserve by customer
  Held -> Paid when payment is Accepted
  Held -> Released when payment is Declined
  stays Held while payment is Unknown
  show status to customer within 2 s
example reponse en attente
  ana = Customer(name: "Ana")
  b = Reserve(customer: ana)
  Pay(b)
  see b is Held
  b.payment = Declined by Bank
  see b is Released

strategy #

strategy is the escape hatch: it names, for a definition, a realisation written elsewhere. No external realisation runs yet. The checker reads the line, reports StrategyNotApplied and leaves native compilation not established (verdict 3); the reference judge runs the definition. To get a native program, remove the line: the definition is what computes the value. The line is written strategy name = Host.op(args) under the definition it concerns.

table #

table gives facts in rows: a name, its key or keys, and the value for each key. Write it at the top of the program, then read it with the table name and a key, as a rate is read with Vat(kind). The table is data, not a rule: it holds the facts you give, and a reading of it works like any other value. The example reads a rate for an item and checks the tax it gives.

forms/table.hector
Verified Example
-- but: le taux de TVA lu dans une table
Clerk
table Vat(kind) -> Ratio
  Food      5.5 %
  Standard  20 %
Item  kind: Food | Standard, price: Money
  vat = price * Vat(kind)
  -> on Sell by Clerk
  show vat to Clerk within 1 s
example tva
  i = Sell(kind: Standard, price: 50 EUR)
  see i.vat = 10 EUR

the #

the picks the element that is best under a rule: the Truck minimizing Truck.load is the truck with the smallest load. Several keys are read in order, each with its own direction, and where keeps only the candidates that satisfy a condition. With the X where c alone, the result is the unique element: two candidates are refused. When no element qualifies, the result is absent, so a reading of its field must allow for it.

forms/the.hector
Verified Example
-- but: le camion le moins charge
Clerk
Truck  name: Text, load: Count
  -> on Park by Clerk
Dispatch  label: Text
  lightest = the Truck minimizing Truck.load
  -> on Open by Clerk
  show lightest.name to Clerk within 1 s
example camion le moins charge
  Park(name: "A", load: 5)
  Park(name: "B", load: 2)
  d = Open(label: "Quai")
  see d.lightest.name = "B"

tie #

tie settles simultaneous changes that a law puts in competition, such as two transitions out of the same status that can fire at the same instant. The one with the smaller number after minimizing wins, and the identity of the change breaks a remaining tie. A real conflict must be settled by a tie, or by the exact fix that Hector proposes. The example pays before the fifteen minutes end, so only the paid transition applies and the release does not fire.

forms/tie.hector
Verified Example
-- but: une reservation payee a temps, ou liberee apres 15 min
Customer  name: Text
Booking  customer: Customer
  status: Held | Paid | Released
  payment: Accepted | Declined by Bank on Pay
  -> Held on Reserve by customer
  Held -> Paid when payment is Accepted
  Held -> Released after 15 min
  tie Held -> Paid minimizing 0
  tie Held -> Released minimizing 1
  show status to customer within 2 s
example paiement a temps
  ana = Customer(name: "Ana")
  b = Reserve(customer: ana)
  Pay(b)
  b.payment = Accepted by Bank
  see b is Paid

to #

to names the observer of a show: a role such as Clerk, a person, or a field of the row such as shopper. It is also an access right: a value shown to one observer is not given to another, so to decides who may read what. One row may have several show lines that name different observers, as the example does for the total and the quantity. The example shows the total to the shopper and checks it.

forms/to.hector
Verified Example
-- but: la facture part vers le client, la quantite vers le magasin
Clerk
Shopper  name: Text
Order  shopper: Shopper, qty: Count, price: Money
  total = qty * price
  -> on Place by Clerk
  show total to shopper within 2 s
  show qty to Clerk within 2 s
example facture
  ana = Shopper(name: "Ana")
  o = Place(shopper: ana, qty: 3, price: 5 EUR)
  see o.total = 15 EUR

Unknown #

Unknown is the value of a choice made by the world while no final answer is known. A field declared by Bank is asked at birth and reads Unknown until the answer arrives; a field asked by on Ask is absent until that event asks it, then reads Unknown. Hector adds that case itself: the author does not write a pending status, and a condition that tests it waits. The example asks the question, then checks that the answer is still Unknown while the order is still waiting.

forms/Unknown.hector
Verified Example
-- but: une commande attend la reponse de la banque
Customer  name: Text
Order  customer: Customer
  status: Waiting | Done
  answer: Accepted | Declined by Bank on Ask
  -> Waiting on Place by customer
  Waiting -> Done when answer is Accepted
  show status to customer within 2 s
example reponse inconnue
  ana = Customer(name: "Ana")
  o = Place(customer: ana)
  Ask(o)
  see o.answer is Unknown
  see o is Waiting

use #

use instantiates a package: a Hector file whose holes ?X are parameters, filled by the use line.

?Subject needs member: Type asks the caller for a member. Inside the subject block, export member: Type promises a field or computed member that the block supplies. Hector checks the readable type at use. A bare choice lists all of its cases and ? allows absence. The public version records the promises of a subject with explicit exports and the inferred interface of other subjects. Names declared by the package itself are local to each instance. Packages without explicit exports keep their existing public version rules. A shown member that only its start declares is recorded with that line, since its type is read there.

An export list also names events (export Account, Open). An exported event keeps its own name in every program that uses the package, so a host calls it as it calls the package written alone, and build --lib --admits can admit the bindings generated for that program. An event the package keeps is renamed for its instance. Two instances that export one event are refused (PackageInterface): one call would reach both. The lock's public version holds the call of each exported event, read from the world of a program that only writes use of the package: the inputs its lines ask for with their types and ranges, its parameters and who may send it (by). A line that asks the caller nothing more moves nothing. A library no program can use unbound (a parameter only a use binds) has no such world: its version holds the lines that name the event, with what their blocks show, so any change to them moves it. A line outside the package that asks a caller of an exported event for more (an input, a parameter, a by) is refused at that line, at the pin and at every read: write it in the package, or send it by an event of another name. hector describe <project> --topology names each linked package, with the stamp its lock holds, before the census: the packages are compiled into one process, and the distributed forms (Split, Copy) stay absent below their threshold.

A top-level export policy block publishes Pact clauses. Its indented prefer and restrict lines apply with their ordinary Pact scopes after binding the package parameters. The lock's public version includes these clauses. Pact clauses outside the block still apply and remain private to the version. One use Survey(Subject = Ticket, respondent = author, done = Closed) gives the tickets their own copy of the rules; two use lines make two separate instances. A project is a directory: the package file and a main program that holds the use line and the examples. The example runs the directory as a whole, and checks the survey sent once a ticket is closed.

forms/use/Survey.hector
Verified Example
-- Satisfaction survey: a package of rules, used by 12-helpdesk-complet.hector.
-- Parameters: ?Subject is the sort surveyed, ?respondent the path to who answers, ?done the status that sends the survey.
-- A survey is sent when the subject reaches ?done, rated 1 to 5 by the respondent, and lapses after 7 days.
?Subject
  survey: Idle | Sent | Rated | Lapsed
  rating: Count 1..5?
  Idle -> Sent when ?done
  Sent -> Rated on Rate(rating) by ?respondent
  Sent -> Lapsed after 7 day
  show survey, rating to ?respondent
forms/use/main.hector
Verified Example
-- but: enquete de satisfaction sur chaque ticket ferme
Person

Ticket  author: Person
  status: Open | Closed
  -> Open on Start by author
  Open -> Closed on Close by author

use Survey(Subject = Ticket, respondent = author, done = Closed)

example enquete envoyee
  ana = Person
  t = Start(author: ana)
  Close(t)
  see t.survey = Sent

when #

when alone fires as soon as its condition becomes true, including when only time passes. The transition takes place at the first instant at which the condition holds, and the clock has its own grain. After an event, on E ... when c is a precondition read on the state before E, not a law. The example moves the clock three days ahead and checks that the order is late; an invariant that must always hold is a law instead.

forms/when.hector
Verified Example
-- but: une commande non payee au bout de 3 jours est en retard
Customer  name: Text
Order  customer: Customer
  status: Waiting | Paid | Late
  -> Waiting on Place by customer
  Waiting -> Paid on Pay by customer
  Waiting -> Late when age(self) >= 3 day
  show status to customer within 1 s
example retard
  ana = Customer(name: "Ana")
  o = Place(customer: ana)
  after 3 day
  see o is Late

where #

where means "such that": it filters a collection, as in count(Book where Lent), or restricts what an observer sees. A bare status name after where tests each element, and a field compared with = tests its value. Prefix the sort, as the example does with books, so that the reader sees which collection is filtered. Only the elements for which the condition holds are counted or shown.

forms/where.hector
Verified Example
-- but: le nombre de livres sortis du comptoir
Clerk
Book  title: Text
  status: Shelf | Lent
  -> Shelf on Add by Clerk
  Shelf -> Lent on Lend by Clerk
Desk  label: Text
  lent = count(Book where Lent)
  -> on Open by Clerk
  show lent to Clerk within 1 s
example deux prets
  Add(title: "Atlas")
  b = Add(title: "Hector")
  Add(title: "Index")
  Lend(b)
  d = Open(label: "Comptoir")
  see d.lent = 1

why #

Write why after the shown names, as in show total why to Clerk, to request an explanation on demand. The ordinary read still gives the value. hector serve requires --journal <path> for a program that declares why, and with --web answers /why to an observer that asks with its declared key, for the rows it is shown, saying nothing but what its own shows write. The host contract says it of those shows alone: their show lines end with why. With hector why <program> --journal <path> <Sort.member> <key>, the local command explains a field or a definition directly shown to an outside observer, for a row its show reaches. A field: the last recorded input that changed it and the declared line that wrote it. A definition: its line, the latest writes among the values it read, at most 8, and how many others it read. A value no input wrote: the last input refused for the row and, in a program without a secret field, the judge reasons. It uses the program revision bound to a single-epoch journal. The example checks the value itself.

forms/why.hector
Verified Example
-- but: le total d'une commande, avec sa provenance
Clerk
Order  qty: Count, price: Money
  total = qty * price
  -> on Place by Clerk
  show total why to Clerk within 1 s
example total
  o = Place(qty: 3, price: 5 EUR)
  see o.total = 15 EUR

within #

within gives the freshness asked for an observation: the value shown is no older than the duration given. Give it an exact duration such as within 2 s. Inside an aggregate, count(Arrival within 5 s) reads the population with the same sliding window as count(Arrival per 5 s). The age boundary is inclusive. Write it after the observer and before any where or by in the same line. The example shows a stock with a two-second freshness and checks the quantity it holds.

forms/within.hector
Verified Example
-- but: un rayon affiche dans les deux secondes
Clerk
Stock  item: Text, qty: Count
  label = item
  -> on Add by Clerk
  show label, qty to Clerk within 2 s
example rayon frais
  s = Add(item: "Pain", qty: 4)
  see s.qty = 4

Reference entries for the types a program writes and the expression forms that build their values. Each entry says what the value holds, how it is written, what Hector derives or refuses, and one trap.

Text #

A Text is a string of characters between double quotes, with the escapes \", \\, \n, \t and \u{E9}. Join texts with +, change their case with upper and lower, and count their characters with length. Hector keeps a text field up to date from its definition, and reads the join and the count from the program. Trap: length gives an offset counted in characters, so compare it with 3 char; a bare 3 is refused as LiteralWithoutUnit.

structure/text.hector
Verified Example
-- but: une étiquette de texte : majuscules, concaténation et longueur
Clerk
Label  name: Text
  shout = upper(name) + " (" + name + ")"
  size = length(name)
  -> on Print by Clerk
  show shout, size to Clerk within 1 s
example etiquette
  l = Print(name: "ana")
  see l.shout = "ANA (ana)"
  see l.size = 3 char

Bytes #

A Bytes value is a sequence of octets, the value of a public format: it is not a text. A format is a composed value whose fields carry a width, such as size: Count 4 byte and flag: Count 1 byte, read in the order written. The intended encoding follows those widths and their order. The example checks the input fields. Its four-byte count leaves byte order open. With an explicit order on each multibyte count, encode(self) produces bytes in declaration order. decode(bytes, T) interprets a complete buffer as the declared single-constructor value T.

structure/bytes.hector
Verified Example
-- but: déclarer une trame à largeurs fixes et demander son encodage ; le résultat reste à établir
Clerk
Frame  size: Count 4 byte, flag: Count 1 byte
  wire = encode(self)
  -> on Build by Clerk
  show wire to Clerk within 1 s
example trame
  f = Build(size: 300, flag: 1)
  see f.size = 300
  see f.flag = 1

Instant #

An Instant is a moment, written as a date or a date with a time: 2026-11-10 or 2026-11-10T08:30. Adding a duration to an instant gives an instant (opens + 8 h), and subtracting two instants gives a duration (now - opens). Hector moves now with the clock and derives every instant from the rows and fields it reads. Trap: an instant literal has no unit and a duration does, so opens + 8 is refused as LiteralWithoutUnit; write 8 h.

structure/instant.hector
Verified Example
-- but: un créneau de travail commence à une heure donnée et finit huit heures plus tard
Clerk
Shift  opens: Instant
  until = opens + 8 h
  waited = now - opens
  -> on Open by Clerk
  show until, waited to Clerk within 1 s
example poste
  s = Open(opens: 2026-11-10T08:30)
  see s.until = 2026-11-10T16:30
  at 2026-11-10T10:00
  see s.waited = 90 min

Day, Week, Month, Year #

These are calendar periods: day(at) gives the calendar day of an instant, and month and year give the month and the year of one; Week is the same kind of period. A field may hold one, such as day: Day, and a birth may set it from a date literal such as 2026-11-10. Hector derives the period from the instant, so two instants on the same calendar day give the same value and a rule can group them. Trap: a period drops the time of day, so two arrivals at 09:00 and 18:30 are equal by day; a rule that needs the hour must read the instant itself.

structure/day.hector
Verified Example
-- but: une garde planifiée pour un jour calendaire ; deux arrivées du même jour tombent dans le même jour
Clerk
Shift  day: Day
  -> on Plan(day: Day) by Clerk
  show day to Clerk within 1 s
Visit  at: Instant
  period = day(at)
  -> on Arrive by Clerk
  show period to Clerk within 1 s
example un jour
  s = Plan(day: 2026-11-10)
  v = Arrive(at: 2026-11-10T09:00)
  w = Arrive(at: 2026-11-10T18:30)
  see v.period = w.period
  see v.period = s.day

Point, Vector #

A Point is a position and a Vector is a displacement; both have the components .x and .y, and both take their unit on the type: Point m, Vector m/s. A value is a pair in parentheses with its unit on the value: (1, 2) m. A point plus a vector is a point, and dist(a, b) gives the length between two points. Hector derives sums and distances from the units, so dist already returns a length with no declaration. Trap: a point or a vector takes its unit on the type, but a Length never does: Length m is refused as PlaneLeak.

structure/point.hector
Verified Example
-- but: un marcheur avance d'un pas ; la distance parcourue est la norme du pas
Clerk
Walker  pos: Point m, step: Vector m
  goal = pos + step
  gap = dist(pos, goal)
  -> on Walk by Clerk
  show goal, gap to Clerk within 1 s
example un pas
  w = Walk(pos: (1, 2) m, step: (3, 4) m)
  see w.goal = (4, 6) m
  see w.gap = 5 m

Fixed #

Fixed(i, f) is a number with i integer bits and f fraction bits, such as Fixed(8, 8); each operation is exact and checked against those bits. Give it a start with start level = 0 and change it with a next on an event, as the example does with next level = level + 1 on Step. Hector controls exactness and range at each operation, so a value that leaves the format is refused rather than rounded in silence. Trap: a bare number passed to a Fixed field from an event (Set(level: 2), 0.5, 50 %) was refused as ExampleArgument by hector check, so such a field is reached through definitions.

structure/fixed.hector
Verified Example
-- but: un compteur en virgule fixe 8.8 : il avance d'un pas à chaque appel ; son double reste exact
Clerk
Gauge  level: Fixed(8, 8)
  doubled = level + level
  -> on Open by Clerk
  start level = 0
  next level = level + 1 on Step by Clerk
  show doubled to Clerk within 1 s
example pas
  g = Open
  Step(g)
  Step(g)
  see g.doubled = 4

Seq #

Seq(T) is an ordered list of values: write it with brackets, [a, b], and read it with length, first and rest. A list keeps the order it was given, and nothing sorts it for you; first gives the head and rest the tail. Hector derives length, first and rest from the list held in the field, so each reading follows the list it was given. Trap: the same brackets mean a list, a set or a map depending on the type expected, and [] is the empty value of that type.

structure/seq.hector
Verified Example
-- but: une file de tâches ordonnée ; la première est la prochaine
Clerk
Queue  tasks: Seq(Text)
  waiting = length(tasks)
  head = first(tasks)
  after_head = length(rest(tasks))
  -> on Load by Clerk
  show waiting, head to Clerk within 1 s
example file
  q = Load(tasks: ["scan", "print", "mail"])
  see q.waiting = 3
  see q.head = "scan"
  see q.after_head = 2

Set #

Set(T) is a collection without order: write it with brackets, ["Ana", "Bob"], and test membership with in. Hector reads a set by its count and by membership, never by position, so length and in are the readings to use. A set field is derived like any other field, and the example checks both the count and the membership of one name. Trap: a set has no first element, so a question about which member comes first belongs to a Seq, not to a Set.

structure/set.hector
Verified Example
-- but: un club a des membres sans ordre ; on demande si quelqu'un en fait partie
Clerk
Club  members: Set(Text)
  size = length(members)
  -> on Found by Clerk
  show size to Clerk within 1 s
example un club
  c = Found(members: ["Ana", "Bob"])
  see "Bob" in c.members
  see c.size = 2

Map #

Map(K, V) pairs each key with one value: write it with [key: value], read one value with get(map, key), and the keys with keys(map). A key the map does not hold gives no value at all. Hector derives the lookup from the map held in the field, so a missing key reads as absent in every rule that uses it. Trap: a missing key is absent, not zero: the price of an unknown product is shown as an em dash, never 0 EUR, and it is tested with not any(...).

structure/map.hector
Verified Example
-- but: un catalogue de prix par produit ; un produit absent n'a pas de prix
Clerk
Shop  prices: Map(Text, Money)
  listed = length(keys(prices))
  bread = get(prices, "pain")
  -> on Stock by Clerk
  show listed, bread to Clerk within 1 s
example catalogue
  s = Stock(prices: ["pain": 2 EUR, "lait": 1 EUR])
  see s.listed = 2
  see s.bread = 2 EUR
  t = Stock(prices: ["vin": 9 EUR])
  see not any(t.bread)

Optional values (T?) #

T? marks a value that may be absent: write note: Text? in a field, and test its presence with any(note). An absent value is written none, so Open(note: none) is a birth without a note, as the example checks. Hector treats any path through an empty T? as absent, and an aggregate skips the absent items instead of failing. Trap: the familiar spellings x is none and x = none are read as not any(x), and a fallback is written with if any(x) else.

structure/optional.hector
Verified Example
-- but: une note facultative : sans note, le libellé de repli s'affiche
Clerk
Ticket  note: Text?
  label = note if any(note) else "sans note"
  -> on Open by Clerk
  show label to Clerk within 1 s
example avec et sans note
  a = Open(note: "urgent")
  see a.label = "urgent"
  b = Open(note: none)
  see b.label = "sans note"

Statuses #

A status is a field of named states, written status: Locked | Open in a block; it is never a Bool, and the birth names the state a row starts in. A transition such as Locked -> Open on Unlock moves a row only from the state it names, and is reads the current state. Hector derives which events are refused from each state; a status that no line enters is a hole, the decision how a row enters it. Trap: a Bool state is refused as BoolState with a fix that names the two states, and a state with no entering line is the hole Unreachable (verdict 3) until a line enters it.

structure/statuses.hector
Verified Example
-- but: une porte est verrouillée ou ouverte ; son état est un nom, jamais un booléen
Clerk
Door  label: Text
  status: Locked | Open
  -> Locked on Install by Clerk
  Locked -> Open on Unlock by Clerk
  Open -> Locked on Lock by Clerk
  show status to Clerk within 1 s
example porte
  d = Install(label: "A")
  see d is Locked
  Unlock(d)
  see d is Open
  refused Unlock(d)
  Lock(d)
  see d is Locked

Composite values (sums) #

A composite value is a sum of cases, each with its own fields: Charge = Cash(amount: Money) | Card(amount: Money, fee: Money). An event passes one case with its fields, as Pay(paid: Cash(amount: 20 EUR)), and a match gives one result per case, the case fields being named bare. Hector checks that a match covers every case or has an else, and derives the value from the case that holds. Trap: a match that misses a case and has no else is refused as NonExhaustive, so every case of the sum must be listed.

structure/composite.hector
Verified Example
-- but: un paiement est en espèces ou par carte ; le montant dû dépend du moyen
Clerk
Charge = Cash(amount: Money) | Card(amount: Money, fee: Money)
Sale  paid: Charge
  owed = match paid
    Cash -> amount
    Card -> amount + fee
  -> on Pay by Clerk
  show owed to Clerk within 1 s
example deux moyens
  s = Pay(paid: Cash(amount: 20 EUR))
  see s.owed = 20 EUR
  t = Pay(paid: Card(amount: 20 EUR, fee: 1 EUR))
  see t.owed = 21 EUR

Arithmetic and comparison #

Numbers combine with +, -, * and /, and compare with =, !=, <, <=, > and >=; conditions combine with and, or and not. Units must agree: a speed is a distance over a duration (distance / time), and a law such as speed <= 120 km/h refuses the event that breaks it. Hector derives each result from its operands and their units, and refuses a sum of two different dimensions as DimensionMismatch. Trap: = defines in a definition and tests in an example; total = total + x is refused as Reassign, because a definition never updates itself.

structure/arithmetic.hector
Verified Example
-- but: une course : la vitesse est la distance divisée par la durée ; une vitesse au-delà de 120 km/h n'est pas enregistrée
Clerk
Trip  distance: Length, time: Duration
  speed = distance / time
  law speed <= 120 km/h
  show speed to Clerk within 1 s
  -> on Log by Clerk
example course
  t = Log(distance: 90 km, time: 1 h)
  refused Log(distance: 150 km, time: 1 h)
  see t.speed = 90 km/h

Aggregates #

sum, count, min and max read the rows held by a field: sum(lines.price) adds the price of every line of the row, and where keeps only some of them. Write each aggregate once as a definition; Hector keeps it up to date as lines are added. An empty sum is 0 EUR, while min and max of nothing are absent. Trap: an aggregate over a field reads only the rows of the row it sits in (lines inside Order), so a line of another order is never counted; a sort name such as count(Line) counts every line.

structure/aggregates.hector
Verified Example
-- but: une commande : total, nombre de lignes et plus forte ligne se déduisent des lignes
Clerk
Order
  total = sum(lines.price)
  count_lines = count(lines)
  dearest = max(lines.price)
  -> on Open by Clerk
  show total, count_lines to Clerk within 1 s
Line  order: Order, price: Money
  law price > 0 EUR
  -> on Add by Clerk
example commande
  o = Open
  e = Open
  Add(order: o, price: 5 EUR)
  Add(order: o, price: 12 EUR)
  see o.total = 17 EUR
  see o.count_lines = 2
  see o.dearest = 12 EUR
  see e.total = 0 EUR

Conditional expression #

a if c else b gives a when c holds and b otherwise; it is an expression that names a value and never assigns one. Both branches give values of the same unit, so a fee stays money whichever branch is taken. When c is absent, the result is b; an unknown c gives Unknown, not the else value. Trap: a conditional always needs both branches; to pick among three cases, define an intermediate value first, as the example does with base.

structure/conditional.hector
Verified Example
-- but: un envoi coûte 5 EUR, 9 EUR s'il est urgent ; au-dessus de 50 EUR il part gratuitement
Clerk
Parcel  price: Money, rush: Normal | Urgent
  base = 5 EUR if rush is Normal else 9 EUR
  fee = 0 EUR if price >= 50 EUR else base
  -> on Send by Clerk
  show fee to Clerk within 1 s
example frais
  a = Send(price: 60 EUR, rush: Urgent)
  see a.fee = 0 EUR
  b = Send(price: 20 EUR, rush: Urgent)
  see b.fee = 9 EUR
  c = Send(price: 20 EUR, rush: Normal)
  see c.fee = 5 EUR

Reference entries for the quantity types of Hector. Each entry says what the type measures, which units write it, what combines with it, and the trap to avoid. A value is written with a unit (500 EUR), and two values combine only when their dimensions agree.

Money #

Money measures an amount of currency: what is owed, paid or priced. Units: EUR and USD, both Money; the symbol keeps them apart. Money times a Ratio is Money (amount * discount), and Money divided by a Duration is a rate such as EUR/h. Adding Money to a Length is refused with DimensionMismatch, so 1 EUR + 1 m never holds. Trap: a literal needs its unit, so write 0 EUR or a value such as 100 EUR; only zero may stay bare.

types/Money.hector
Verified Example
-- but: une facture dont le montant net retire la remise
Clerk
Invoice  amount: Money, discount: Ratio
  net = amount - amount * discount
  show net to Clerk within 1 s
  -> on Issue by Clerk

example facture remisee
  i = Issue(amount: 100 EUR, discount: 10 %)
  see i.net = 90 EUR

Length #

Length measures a distance along one line: a width, a depth, a gap. Units: m, km, cm and mm (1 km is 1000 m, 1 cm is one hundredth of a metre). Length times Length is an Area, Length times Length times Length is a Volume, and Length divided by Duration is a Speed. Adding a Length to a Duration is refused with DimensionMismatch. Trap: the bare 2 in 2 * (width + depth) is a count and is allowed; a Length literal always carries its unit, such as 3 m.

types/Length.hector
Verified Example
-- but: le tour d'une piece rectangulaire
Clerk
Room  width: Length, depth: Length
  perimeter = 2 * (width + depth)
  show perimeter to Clerk within 1 s
  -> on Measure by Clerk

example tour de la piece
  r = Measure(width: 3 m, depth: 2 m)
  see r.perimeter = 10 m

Mass #

Mass measures the quantity of matter, weighed in kilograms. Units: kg, g, mg and t (1 t is 1000 kg). Mass times Count is Mass, which totals a pallet of identical boxes; Mass times an acceleration such as 10 m/s2 is a Force. Mass and Money do not add, so a weight never sums with a price. Trap: a Mass is held at the finest step the lines of the program write, a whole kg when they write none; an input finer than that step is refused (HISTORY_VALUE_OFF_GRAIN, in a history as in an example) with the line to write to hold it.

types/Mass.hector
Verified Example
-- but: le poids d'une palette de caisses identiques
Clerk
Pallet  crate: Mass, boxes: Count
  total = crate * boxes
  show total to Clerk within 1 s
  -> on Load by Clerk

example palette de douze caisses
  p = Load(crate: 5 kg, boxes: 12)
  see p.total = 60 kg

Duration #

Duration measures a span of time: a delay, a shift, a timeout. Units: s, ms, us, ns, min, h, day, week, month and year; the words days, hours, minutes and seconds are read as these units. Duration times a Count is Duration, and Duration divided by a Count is a Duration; Money divided by Duration is a rate, and one over a Duration is a Frequency. An instant minus an instant is a Duration, so now - slot gives the time elapsed. after reads a duration expression, including a named duration. within takes an exact duration literal, including a ratio with a unit, or the name of a world value defined directly by such a literal; it does not resolve arbitrary expressions or chains of names. A number without a duration unit is refused.

types/Duration.hector
Verified Example
-- but: la moitie d'un poste de travail
Clerk
Shift  span: Duration
  half = span / 2
  show half to Clerk within 1 s
  -> on Plan by Clerk

example poste de huit heures
  s = Plan(span: 8 h)
  see s.half = 4 h

Frequency #

Frequency measures how often something repeats, per second. Units: Hz and kHz (1 kHz is 1000 Hz). One over a Frequency is a Duration, so period = 1 / rate gives the period of a clock, as the example checks. Frequency times Duration has no dimension left, so it is a plain number of cycles. Trap: a Frequency is a count per second; it is not a rate of money, and it does not add to a Duration.

types/Frequency.hector
Verified Example
-- but: la periode d'une horloge, deduite de sa frequence
Clerk
Clock  rate: Frequency
  period = 1 / rate
  show period to Clerk within 1 s
  -> on Tune by Clerk

example horloge a quatre hertz
  k = Tune(rate: 4 Hz)
  see k.period = 0.25 s

Force #

Force measures a push: mass times acceleration, in newtons. Units: N only; N is kg times m/s2, so 2 kg * 10 m/s2 is 20 N. Force times Length is an Energy, and Force divided by Area is a Pressure. Adding a Force to a Mass or a Speed is refused with DimensionMismatch. Trap: an acceleration is written with m/s2, not m/s, which is a Speed.

types/Force.hector
Verified Example
-- but: le poids d'une masse sous la pesanteur
Clerk
Load  mass: Mass
  weight = mass * 10 m/s2
  show weight to Clerk within 1 s
  -> on Hang by Clerk

example masse de deux kilos
  l = Hang(mass: 2 kg)
  see l.weight = 20 N

Pressure #

Pressure measures a force spread over a surface: how hard the surface is pushed. Units: Pa, kPa and bar (1 bar is 100000 Pa). Pressure is Force divided by Area, and Pressure times Area is a Force. Adding a Pressure to a Force is refused with DimensionMismatch. Trap: the area in the example is written 2 m2, an Area, so 100 N / 2 m2 gives the Pressure 50 Pa.

types/Pressure.hector
Verified Example
-- but: la pression sous un plateau, force divisee par surface
Clerk
Plate  force: Force, area: Area
  pressure = force / area
  show pressure to Clerk within 1 s
  -> on Press by Clerk

example plateau de deux metres carres
  p = Press(force: 100 N, area: 2 m2)
  see p.pressure = 50 Pa

Energy #

Energy measures work done or charge stored: power times duration. Units: J, kJ, Wh, kWh and MWh (1 kWh is 3600000 J). Power times Duration is an Energy, and Force times Length is an Energy; Energy divided by Duration is a Power. Adding an Energy to a Power is refused with DimensionMismatch. Trap: a battery power in kW and a span in h multiply directly, so 2 kW * 3 h gives 6 kWh with no conversion.

types/Energy.hector
Verified Example
-- but: l'energie d'une batterie, puissance fois duree
Clerk
Battery  power: Power, span: Duration
  stored = power * span
  show stored to Clerk within 1 s
  -> on Charge by Clerk

example batterie de deux kilowatts
  b = Charge(power: 2 kW, span: 3 h)
  see b.stored = 6 kWh

Power #

Power measures the rate at which energy is used or delivered. Units: W, kW and MW (1 MW is 1000000 W). Energy divided by Duration is a Power, and Power times Duration is an Energy. A Power is not a Money per time, although Money/h looks alike: the dimensions differ, and their sum is refused. Trap: an Energy in kWh over a Duration in h gives kW, so 6 kWh / 3 h is 2 kW, as the example checks.

types/Power.hector
Verified Example
-- but: la puissance moyenne, energie divisee par duree
Clerk
Heater  used: Energy, span: Duration
  power = used / span
  show power to Clerk within 1 s
  -> on Log by Clerk

example chauffage de six kilowattheures
  h = Log(used: 6 kWh, span: 3 h)
  see h.power = 2 kW

Angle #

Angle measures a turn or a heading, in degrees. Units: deg only. Angle adds to and subtracts from another Angle; it does not multiply with a Length. Trap: a plain sum does not wrap in this checker: 359 deg + 2 deg stays 361 deg, a known difference: FICHE.md promises the periodic 1 deg. The periodic reading, 359 deg + 2 deg = 1 deg, is written with mod(start + turn, 360 deg), as the example does.

types/Angle.hector
Verified Example
-- but: un cap qui tourne ; le tour complet ramene a zero
Pilot
Heading  start: Angle, turn: Angle
  course = mod(start + turn, 360 deg)
  show course to Pilot within 1 s
  -> on Steer by Pilot

example cap qui passe le nord
  h = Steer(start: 359 deg, turn: 2 deg)
  see h.course = 1 deg

Temperature #

Temperature measures a thermal level, in kelvins or in degrees Celsius. Units: K and degC; 0 degC is 273.15 K, so 0 degC is not 0 K; the sign belongs to the number written, so -10 degC is 263.15 K. Temperature is absolute: a setpoint plus 10 K is another temperature on the same scale. In a compound unit such as degC/s only the size of degC counts, not its zero. Trap: keep a temperature in the unit it was given; the example writes 300 K and 310 K.

types/Temperature.hector
Verified Example
-- but: une consigne de four, en kelvins
Operator
Oven  setpoint: Temperature
  hotter = setpoint + 10 K
  show hotter to Operator within 1 s
  -> on Set by Operator

example four a trois cents kelvins
  f = Set(setpoint: 300 K)
  see f.hotter = 310 K

Area #

Area measures a surface: a Length times a Length. Units: m2 (the square of m) and ha (1 ha is 10000 m2). Length times Length is an Area, Area times Length is a Volume, and Area divided by Length is a Length. Adding an Area to a Volume is refused with DimensionMismatch. Trap: the square is written with a digit, m2, and the example writes 12 m2 for a 3 m by 4 m plot.

types/Area.hector
Verified Example
-- but: la surface d'une parcelle rectangulaire
Clerk
Plot  width: Length, depth: Length
  area = width * depth
  show area to Clerk within 1 s
  -> on Survey by Clerk

example parcelle de trois sur quatre
  p = Survey(width: 3 m, depth: 4 m)
  see p.area = 12 m2

Volume #

Volume measures a space: a tank, a vessel, a room's air. Units: L and mL (1 L is 1000 mL); a cubic metre written m3 is also a Volume. Area times Length is a Volume, and Length times Length times Length is a Volume. Adding a Volume to an Area is refused with DimensionMismatch. Trap: a litre is a Volume like a cubic metre, so 10 L - 4 L gives 6 L, as the example checks.

types/Volume.hector
Verified Example
-- but: le volume restant d'une cuve, capacite moins niveau
Operator
Vessel  capacity: Volume, filled: Volume
  room = capacity - filled
  show room to Operator within 1 s
  -> on Fill by Operator

example cuve de dix litres a moitie pleine
  v = Fill(capacity: 10 L, filled: 4 L)
  see v.room = 6 L

Speed #

Speed measures distance over time. It has no unit of its own and is written by composition: m/s, km/h. Length divided by Duration is a Speed, and Speed times Duration is a Length. Adding a Speed to a Length is refused with DimensionMismatch. Trap: the example writes 10 km over 2 h and gives 5 km/h; a speed literal carries its unit, as 12 m/s.

types/Speed.hector
Verified Example
-- but: une vitesse moyenne, distance divisee par duree
Coach
Run  distance: Length, span: Duration
  speed = distance / span
  show speed to Coach within 1 s
  -> on Record by Coach

example course de dix kilometres en deux heures
  r = Record(distance: 10 km, span: 2 h)
  see r.speed = 5 km/h

Size #

Size measures data: how many bytes, bits or kilobytes a value takes. Units: byte, bit (8 bit is 1 byte), KB (1000 byte) and MB (1000000 byte). Size times a Count is a Size, and Size divided by Duration is a rate of bytes per second. Adding a Size to a Count is refused with DimensionMismatch. Trap: KB and MB are decimal here (1000 and 1000000 bytes), not 1024-based.

types/Size.hector
Verified Example
-- but: la taille d'un envoi, doublee quand on le copie
Operator
Upload  size: Size
  copies = size * 2
  show copies to Operator within 1 s
  -> on Send by Operator

example envoi de trois kilooctets
  u = Send(size: 3 KB)
  see u.copies = 6 KB

Offset #

Offset measures a position in a text, counted in characters: the unit is char. Units: char only. Offset plus an Offset is an Offset, so a start plus a length gives the stop position, as the example checks. Adding an Offset to a Length is refused with DimensionMismatch: a text position is not a distance. Trap: a position and a count of characters are both char, so 3 char + 4 char is 7 char.

types/Offset.hector
Verified Example
-- but: la fin d'un jeton dans un texte, debut plus longueur
Editor
Token  start: Offset, length: Offset
  stop = start + length
  show stop to Editor within 1 s
  -> on Cut by Editor

example jeton de quatre caracteres
  t = Cut(start: 3 char, length: 4 char)
  see t.stop = 7 char

Ratio #

Ratio measures a share with no unit of its own, written with the sign %. Units: % only; 25 % is one quarter, the value 0.25. Ratio times Money is a Money, and 1 - rate gives the complement of a share, as the example checks. Ratio has no dimension, so it multiplies with a Count or another Ratio without refusal. Trap: a bare 25 is a Count, not a Ratio; write 25 % for a share.

types/Ratio.hector
Verified Example
-- but: la part d'un montant qui reste apres une remise
Clerk
Sale  rate: Ratio, base: Money
  kept = 1 - rate
  show kept to Clerk within 1 s
  -> on Ring by Clerk

example vente remisee de vingt-cinq pour cent
  s = Ring(rate: 25 %, base: 80 EUR)
  see s.kept = 75 %

Count #

Count measures a number of things: rows, places, items. It has no unit. A Count is written as a bare whole number, 4 or 24, never 4 Count. Count times Money is a Money, and Count times Duration is a Duration. A Count is whole by definition, so a fraction of a row is not a Count. Trap: 500 Count is not written; the number alone is the value.

types/Count.hector
Verified Example
-- but: le nombre de places d'une etagere, rangees fois colonnes
Clerk
Shelf  rows: Count, columns: Count
  places = rows * columns
  show places to Clerk within 1 s
  -> on Stock by Clerk

example etagere de quatre rangees
  s = Stock(rows: 4, columns: 6)
  see s.places = 24

Quantity #

Quantity is the generic quantity of a function parameter: it stands for a quantity of any dimension. It is written only on a parameter, as in twice(q: Quantity) = q + q, and the type of each call decides the result. The example calls it with a Length, and the field it doubles is still a Length. Trap: a Quantity parameter has no dimension of its own, so a field of a named type such as Length or Money is what a sort declares.

types/Quantity.hector
Verified Example
-- but: une fonction qui double une quantite quelconque
Clerk
Gauge  length: Length
  twice(q: Quantity) = q + q
  doubled = twice(length)
  show doubled to Clerk within 1 s
  -> on Read by Clerk

example jauge doublee
  g = Read(length: 3 m)
  see g.doubled = 6 m