Standard library
The standard library
The ready-made actions, inputs, outputs and exercises that every program can import, and how to call them.
Trainerflow comes with a library of ready-made elements that you can use to
write programs faster. We call it the Trainerflow Standard Library, and in
code it goes by the name coach.
As we saw in your first program, defining every action, output and exec from scratch takes a fair amount of ceremony. The standard library has done that work for you: it declares the inputs and outputs that training keeps needing (reps, weight, RPE, durations and so on), and around seventy strength exercises, from the back squat to the snatch, ready to be called.
How to use
Every program depends on the standard library. When you create a program, it
gets the latest release of coach automatically, so there is nothing to
install and nothing to configure. To use a part of it, import the file you
need at the top of any file of your program:
import "coach/strength/squat.cl"
import "coach/common/rest.cl"
squat([weight: 100|kg|, reps: 5], [reps: true], [location: true])
rest(3|min|)
The path of an import names a file of the library, starting with coach/.
Everything the file declares becomes available in the file that imports it.
If two libraries declare something with the same name, an alias tells them
apart; the imports page explains how.
Library files are read-only: a program uses them as they are and cannot change them.
The standard library is released in versions, so a program keeps behaving the same way as the library grows. These pages document a single version, which each reference page shows at the top.
Structure
The library is organised in a handful of files:
| Import | What it holds |
|---|---|
coach/common/elements.cl |
Durations, comments and RPE, which every kind of training needs. |
coach/common/rest.cl |
The rest exec that puts time between sets and sessions. |
coach/athlete.cl |
Inputs that describe the athlete: age, height, body weight, BMI and so on. |
coach/strength/elements.cl |
The inputs and outputs of strength training: weight, reps, RIR and tempo. |
coach/strength/squat.cl |
The squat and its variations, lunges, step-ups and the leg press. |
coach/strength/push.cl |
Pressing movements: bench press, press, push-ups, dips, raises. |
coach/strength/pull.cl |
Pulling movements: rows, pull-ups, curls. |
coach/strength/bend.cl |
Hinging movements: deadlifts, good mornings, hip thrusts. |
coach/strength/core.cl |
Planks, crunches, carries and the like. |
coach/strength/olympic.cl |
The clean, the jerk and their pulls. |
The strength libraries import the elements they need themselves, so importing
coach/strength/squat.cl is enough to call squat.
On top of the library, a few built-in functions, like
round and max, are part of the language itself and need no import at all.
Calling an exercise
Every exercise of the strength libraries is an exec with the same three parameters:
bicep_curl(
[weight: 12|kg|, reps: 10, tempo: [down: 3, bottom: 1, up: 0, top: 0], rpe: 8],
[reps: true, weight: true],
[location: true, variation: "Hammer", set: 1, sets: 3]
)
Each of them is a map, and each can leave out whatever it doesn’t need.
Specs
The first map holds the specs: what the athlete is prescribed. Each exercise lists the specs it understands on its reference page, for example weight, reps or rir, tempo, rpe, comments for the bench press. A spec you leave out is simply not shown to the athlete.
Some specs are alternatives. reps or rir means that the exercise prescribes
reps when you give it reps, and otherwise RIR (reps in reserve) when you give
it rir. If you give both, reps win.
A few specs deserve a word of their own:
tempois a map of the seconds that each phase of a rep takes:down,bottom,upandtop. The athlete sees it in the usual notation, so[down: 3, bottom: 1, up: 0, top: 0]shows as 3-1-X-0. A phase you leave out counts as 0, anupof 0 means “as fast as possible” and shows as X, and a phase that is not a number shows as ?.rpeis a number from 0 to 10, the rate of perceived exertion. The athlete sees the number together with what it means, e.g. “Hard” for 7.commentsis a string, for anything you want to tell the athlete about the set, like “Keep the bar close”.
Measures
The second map holds the measures: what the athlete reports back. Each
key is the name of an input and its value is true to measure it:
let set = squat([weight: 100|kg|, reps: 5], [reps: true, weight: true], [location: true])
The athlete sees the target next to an empty field for each measure, and what
they enter comes back in the exec’s feedback:
set.reps is the number of reps they actually did.
Options
The third map holds the options: how the exercise is shown, and which variation of it the athlete does.
locationdecides the title of the screen.trueshows the exercise’s title, a string shows that string instead (handy for “Warm-up” or “Test”), and leaving it out shows no title at all.titlereplaces the title of the exercise in the athlete’s history.setandsetsnumber the set, so that the athlete sees “set 2 of 3”. They are optional and independent of each other.- Most exercises also have options that pick a variation, a grip or the gear,
each with a fixed list of values.
bench_presshas agrip_styleof"Wide","Close"or"Supinated", which turns its title into “Wide Grip Bench Press”. Some of these options have a default that applies when you leave them out. The reference page of every exercise lists them.
A value that is not in an option’s list is ignored, and the exercise falls back to its default.
Rest
The one exec of the library that is not an exercise is rest, in
coach/common/rest.cl. It takes a single duration:
rest(90|s|)
rest(2|day|)
A short rest shows the athlete a countdown that moves on by itself when it ends. The time and rest page explains how rests shape a week.