Replies: 1 comment
Very neat. I assume using a validator in an if condition would work with the unifying operator, so generality works in the other direction.
I am personally not a fan of functional options and would prefer an options struct. They are easier to overview at the call site and don’t pollute the API docs. It might also play better with an RPC extension, since structs can more easily be transported.
Obviously this should eventually be supported. Would that work transparently by the registered Go function taking a cue.Value, or would that require a new registration function? If it’s the latter, I would suggest putting “Concrete” in the proposed function names. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
📋 Proposal Details:
This proposal introduces a Go API for wrapping ordinary Go functions as CUE-callable functions and validators. It provides a simple, type-safe mechanism for extending CUE's evaluation with custom logic, establishing two distinct concepts: functions (which compute new values from arguments) and validators (which constrain existing values through unification).
See the design document for full details.
This proposal is closely related to #4294 (CUE Value Injection) and #4295 (Tagged String Literals).
All reactions