;; lib/hyperscript/plugins/prolog.sx — Prolog plugin ;; ;; Provides the `prolog` HS-level function. Replaces the ad-hoc ;; hs-prolog-hook / hs-set-prolog-hook! slots that previously lived in ;; lib/hyperscript/runtime.sx (nodes 140–142 of the plugin design doc). ;; ;; Two-step wiring preserves the original API: ;; 1. lib/prolog/runtime.sx loaded → defines pl-query-one ;; 2. lib/prolog/hs-bridge.sx (or this file's auto-wire) calls ;; (hs-set-prolog-hook! (fn (db goal) (not (= nil (pl-query-one db goal))))) ;; If neither is loaded, calling (prolog db goal) raises a clear error. (define hs-prolog-hook nil) (define hs-set-prolog-hook! (fn (f) (set! hs-prolog-hook f))) (define prolog (fn (db goal) (if (nil? hs-prolog-hook) (raise "prolog hook not installed") (hs-prolog-hook db goal))))