Documentation
¶
Overview ¶
Package template fills the templates of tasks: it counts the instances of a template, builds each one with its numbers, and picks the instance of an attempt from the attempt's seed (format/README.md, sections 22 and 23; R60 spec). api calls it for the instance of an attempt, and the check of a module and the build of a package for every instance.
Instances checks a template by the rules of templates that it breaks by itself — task.template-names, task.template-expressions, task.placeholders and task.template-instances — and counts its instances in the order of the odometer, each with its numbers: the expressions of the narrow subset of Starlark, read and typed here and evaluated in the sandbox of internal/sandbox (R32). Instance puts the numbers of an instance in the place of the placeholders, in a single pass, with no expression and no Starlark, as api does with the numbers that the package carries; the open view of an instance is openview.Task of it. AttemptInstance picks the instance of an attempt by its number, from the place of randomness of the attempt's seed that the format gives a template, through internal/random (R31). The results of a solver come with the task of solvers (R16).
Index ¶
Constants ¶
const ( RuleNames = "task.template-names" RuleExpressions = "task.template-expressions" RulePlaceholders = "task.placeholders" RuleInstances = "task.template-instances" )
The rules of templates that a template breaks by itself — by its names, its expressions, its placeholders and the combinations of its parameters — whatever its instances hold (format/README.md, section 23). task.placeholders holds outside a template too, and the check of a module reads it there.
const MaxInstances = 10000
MaxInstances is the most instances a template has: the sizes of its domains multiply to at most 10 000 (format/README.md, section 23).
Variables ¶
var ErrDomain = random.ErrDomain
ErrDomain is what AttemptInstance gives on an argument outside its domain: a count outside 1 to MaxInstances, or an ID that is no name of a place of randomness. It is the generator's own, so that errors.Is finds it whichever of the two gives it.
Functions ¶
func AttemptInstance ¶
AttemptInstance gives the number of the instance that an attempt on a template gets, from 0: below(count) of the place of randomness of the attempt's seed whose names are template, the ID of the task and instance, where count is how many instances the template has, from 1 to MaxInstances (format/README.md, sections 22 and 23; R60 spec). Nothing else draws from that place, so the same package and the same seed give the same instance (R03 spec). The instances are numbered in the order of the odometer, as the package carries their numbers.
api draws the seed from a cryptographic source when the attempt begins and passes it here as a number; neither the seed nor the words of the place reach the learner's device, since the words show the seed (format/README.md, section 22). A count outside its domain gives ErrDomain, and so does an ID that is no name of a place: empty, or holding | or what is not UTF-8. The ID of a valid task is neither (common.schema.json).
func Instance ¶ added in v0.1.19
Instance gives the instance of a template with the numbers of one of its instances: the task with every placeholder replaced by its number, in decimal digits with - before a negative one, and every doubled brace by one, in a single pass, without its template, and with the template's id (format/README.md, section 23). It evaluates no expression and runs no Starlark: api puts in the numbers that the package carries, picked by AttemptInstance, and the open view of the instance is openview.Task of it (section 25).
The error is for a task that is no template, a string of it that breaks task.placeholders, and a placeholder whose number numbers does not give. The instance is not checked against the schema of a task: the check of a module holds every instance of a template to it, by task.instances.
Types ¶
type Breach ¶ added in v0.1.19
type Breach struct {
Rule, Pointer, Message string
}
A Breach is a reason that a template breaks a rule of templates: its Rule, one of RuleNames, RuleExpressions, RulePlaceholders and RuleInstances; the value of the task that breaks it, as a JSON Pointer in URI fragment form, such as #/template/derived/b; and what breaks it.
func Instances ¶ added in v0.1.19
Instances counts the instances of a template and gives the numbers of each, in their order: every parameter and every derived number of the instance, by its name (format/README.md, section 23). The combinations of the parameters come in the order of an odometer — the parameters in the order of their names, the first changing slowest, each through its domain upwards —, and on each the derived numbers are computed and then the constraint, in the sandbox of Starlark; those for which the constraint holds, or all of them when there is none, are the instances.
A template that breaks a rule of templates gives its breaches and no numbers, in the order of spec's second implementation: every breach of its names, its expressions and its placeholders; and only when none of them breaks, those of its combinations — every empty domain, or too many combinations, or the first combination on which an expression fails or a derived number lies past ±(2^53 − 1), where the count stops, or none that gives an instance. A task that is no template gives neither.
The results of a solver are no numbers here: the solver runs with its own task of the epic of code (R16), and its results come then.