tooling/templatize: use typed options, functional core #725
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.
tooling/templatize: use typed options, functional core
The typed options pattern hides the validated and completed options in
opaque types that make it impossible for a consumer of the
ExecuteTemplate()
function to pass some set of options that has NOTbeen validated and completed. This makes it easy to trust the input and
make assumptions about it.
Furthermore, the
Complete()
implementation shows how to implement the"imerative shell, functional core" pattern - imperative functionality
with side-effects like reading the filesystem can be done in a (small)
shell of imperative core, so that the real functionality of the library
is done in functional logic that is trivial to test.
An example of how to use this to our advantage is the new test for
template executioin - we pass raw data in, get raw data out. No need to
worry about filesytems, permissions, etc. We still can worry about
that in end-to-end tests if we need to.
Signed-off-by: Steve Kuznetsov stekuznetsov@microsoft.com
*: use bingo, add formatter target
Signed-off-by: Steve Kuznetsov stekuznetsov@microsoft.com