Repository navigation
Adds a guide to adding host functions - #210
Merged
Merged
Conversation
A how-to page under docs/guides: write a call into a rule, supply the function under the functions option of evaluate, and handle a call that fails (a function left out, a function that throws, an answer outside the value domain), with the result each step shows. The README's Documentation map links it under Do, and the Host functions section's line moves to Look up, where its reference text belongs. Refs: pts-8f7z
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this adds
A how-to page,
docs/guides/how-to-add-host-functions.md: write a call into a rule's text, supply the function under thefunctionsoption ofevaluate, and handle a call that fails (the function left out, a function that throws, an answer outside the value domain). Every example is set in the library loan: a renewal rule that asks the application's hold queue whether another patron is waiting for the copy.The README's Documentation map links the page under Do. The line that pointed Do at the README's Host functions section now points at the page, and that section, which is reference text (how arguments and answers cross into the language's values, how a host name shadows a builtin), gets its own line under Look up. The section itself is unchanged: its example is executed by the README suite, and the page does not replace it.
No file under
src/changes. No changelog fragment:changelog.d/README.mdexcludes documentation.Provenance
callinsrc/evaluator.ts, each result checked against the built package.Results on the page
No test executes
docs/guides/, so every result line on the page is unexecuted by the suite. Each was re-run by hand against the built package, from the page's owntsfences (type-checked withtsc --strict, then executed), with these answers:compiled.instructionsholds["call", "holds_waiting", 1]holdsWaiting(["atlas-2"])answers1renewableis{ ok: true, value: true }heldis{ ok: true, value: false }functionsleft out,okisfalseanderror.reasonis"Unknown function: holds_waiting"error.typeis"EvaluationError"anderror.reasonis the thrown messageerror.reasonis"unsupported_host_value"Checks
README.md: 1169 lines, every part present, no finding.mise exec -- pnpm run gate, whichgate.also_gated_pathsrequires for a README change) green on this commit: typecheck, lint, neutrality, the suite with coverage, corpus check, cites, build, identity, resolution, docs.functions, and the three failure branches) do not appear there.