Gen Integration Reference
Import
Section titled “Import”let ukanren = import ./gen-integration.nix { inherit genMerge genSelect genTypes genScope; };inReturns the standard ukanren attrset merged with all gen-native synthesis functions below.
gen-types-chr
Section titled “gen-types-chr”typeGoal
Section titled “typeGoal”typeGoal :: checker -> var -> goalDeferred type guard using a gen-types checker. Passes while var is unbound; calls checker.verify when ground. Fails if verify returns non-null.
ukanren.chrRun 3 (q: ukanren.conj (ukanren.typeGoal genTypes.int q) (ukanren.eq q 42))# => [ 42 ]intGoal / strGoal / boolGoal
Section titled “intGoal / strGoal / boolGoal”intGoal :: var -> goalstrGoal :: var -> goalboolGoal :: var -> goalShortcuts for typeGoal genTypes.int, typeGoal genTypes.str, typeGoal genTypes.bool.
listOfGoal
Section titled “listOfGoal”listOfGoal :: checker -> var -> goaltypeGoal (genTypes.listOf elemChecker).
nullOrGoal
Section titled “nullOrGoal”nullOrGoal :: checker -> var -> goaltypeGoal (genTypes.nullOr baseChecker).
gen-schema-synth
Section titled “gen-schema-synth”synthFromOptions
Section titled “synthFromOptions”synthFromOptions :: options -> desired -> int -> [{ weight; answer }]Finds completions of desired satisfying options schema. Weight = invented field count. options is an attrset of gen-merge mkOption records.
ukanren.synthFromOptions { port = genMerge.mkOption { type = genMerge.types.int; }; } { port = 8080; } 3synthMinimalOverride
Section titled “synthMinimalOverride”synthMinimalOverride :: base -> options -> desired -> attrsetReturns only the fields of desired that differ from base. Useful for computing config deltas.
ukanren.synthMinimalOverride { port = 80; } options { port = 8080; }# => { port = 8080; }importSel
Section titled “importSel”importSel :: schemaLib -> desired -> int -> [{ weight; answer }]Searches a list of option-attrsets for schemas covering desired. Weight = uninvented fields. answer is a single-element list [ schema ].
gen-select-synth
Section titled “gen-select-synth”synthSelector
Section titled “synthSelector”synthSelector :: positives -> negatives -> int -> [sel]Returns up to n gen-select native selector values ({ __sel = ...; }) that match all positives and none of the negatives. Uses genSelect.matches as oracle.
ukanren.synthSelector [ { kind = "fn"; } ] [ { kind = "var"; } ] 5# => [ { __sel = "attrs"; a = { kind = "fn"; }; } ]gen-merge-backward
Section titled “gen-merge-backward”evalModuleo
Section titled “evalModuleo”evalModuleo :: modules -> var -> goalRelational wrapper for genMerge.evalModuleTree. Unifies q with the merged config of modules.
ukanren.run 1 (q: ukanren.evalModuleo [ modA modB ] q)synthFromModules
Section titled “synthFromModules”synthFromModules :: moduleLib -> desired -> int -> [{ weight; answer; config }]Enumerates subsets of moduleLib (smallest first) whose merged config covers desired. Weight = subset size. config is the full merged config of the subset.
ukanren.synthFromModules moduleLib { port = 8080; } 3gen-scope-synth
Section titled “gen-scope-synth”synthDecls
Section titled “synthDecls”synthDecls :: nodeIds -> parentGraph -> attrDefs -> desired -> candidateDecls -> int -> [{ weight; answer }]Finds minimal declaration sets from candidateDecls satisfying desired attribute evaluations. Weight = total declared field count. Oracle: genScope.eval.
ukanren.synthDecls [ "n1" "n2" ] parentGraph attrDefs [ { id = "n1"; attr = "ty"; value = "Int"; } ] candidateDecls 3