Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup #15

Merged
merged 5 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions shadow-cljs.edn
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
{:web-editor
{:target :esm
:output-dir "public/js"
:modules {:l4_web_editor {:init-fn l4-lp.web-editor.main/init!}}
:devtools {:before-load l4-lp.web-editor.main/stop!
:after-load l4-lp.web-editor.main/start!}
:modules {:l4_web_editor {:init-fn l4-lp.web-editor.core/init!}}
:devtools {:before-load l4-lp.web-editor.core/stop!
:after-load l4-lp.web-editor.core/start!}
:compiler-options {:output-feature-set :es2021
:externs ["datascript/externs.js"]}}

Expand Down
46 changes: 2 additions & 44 deletions src/l4_lp/core.cljc
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
(ns l4-lp.core
(:require #?(:cljs [applied-science.js-interop :as jsi])
#?(:cljs [l4-lp.swipl.js.wasm-query :as swipl-wasm-js-query])
(:require #?(:cljs [l4-lp.swipl.js.wasm-query :as swipl-wasm-js-query])
[l4-lp.syntax.l4-to-prolog :as l4->prolog]
#?(:cljs [promesa.core :as prom])))

Expand All @@ -12,45 +11,4 @@

;; #?(:cljs
;; (def query-and-trace
;; swipl-wasm-js-query/query-and-trace))

#?(:cljs
(prom/let
[program
['(DECIDE p of var/xs and var/x and var/z
IF (var/xs IS THE LIST OF ALL var/y SUCH THAT q holds for var/y)
AND (var/ys IS THE LIST OF ALL var/y SUCH THAT r holds for var/y)
AND (r holds for var/z)
AND (var/x IS (SUM var/xs))
AND (var/y IS (SUM var/ys))
AND (var/y > 0))

'(DECIDE q holds for 0)
'(DECIDE q holds for 1)

'(DECIDE r holds for var/z
IF (var/z IS 3)
OR (var/z IS 4))]

goal '(p of var/xs and var/x and 4)

_ (jsi/call js/console :log "Input L4 program:\n" program)
_ (jsi/call js/console :log "Input L4 goal:\n" goal)

program' (l4->prolog/l4-program->prolog-program-str program)
goal' (l4->prolog/l4->prolog-str goal)

_ (jsi/call js/console :log "Transpiled Prolog program:\n" program')
_ (jsi/call js/console :log "Transpiled Prolog goal:\n" goal')

output (swipl-wasm-js-query/query-and-trace! program' goal')]
(jsi/call js/console :log "Output:\n" output))

#_(->>
"[(DECIDE p of var/x IF ((var/x ** 1) IS 0))
(DECIDE q holds for 1)
(DECIDE q holds for 2)]"

l4->prolog/l4-program->prolog-program-str

(jsi/call js/console :log)))
;; swipl-wasm-js-query/query-and-trace))
7 changes: 3 additions & 4 deletions src/l4_lp/swipl/js/wasm_query.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
[cljs-bean.core :as bean]
[l4-lp.swipl.js.common.swipl-js-to-clj :as swipl-js->clj]
[promesa.core :as prom]
[shadow.esm :refer [dynamic-import]]))
["https://SWI-Prolog.github.io/npm-swipl-wasm/3/7/5/dynamic-import.js"
:as swipl-mod]))

(def ^:private swipl-constructor
(prom/let [cdn-url "https://SWI-Prolog.github.io/npm-swipl-wasm/3/7/5/dynamic-import.js"
mod (dynamic-import cdn-url)]
(jsi/get mod :SWIPL)))
(jsi/get swipl-mod :SWIPL))

(def ^:private prelude-qlf-url
"resources/swipl/prelude.qlf")
Expand Down
6 changes: 2 additions & 4 deletions src/l4_lp/web_editor/codemirror_editor.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@

(def ^:private eval-query-extension
(jsi/call cm-view/keymap :of
#js [#js {:key "Mod-Enter"
:run eval-query!}]))
#js [#js {:key "Mod-Enter" :run eval-query!}]))

(def ^:private theme
(jsi/call cm-view/EditorView :theme
Expand All @@ -48,7 +47,6 @@
(let [editor-elt (jsi/call js/document :getElementById editor-element-id)
state (jsi/call cm-state/EditorState
:create
#js {:doc code
:extensions extensions})]
#js {:doc code :extensions extensions})]
(cm-view/EditorView.
#js {:parent editor-elt :state state})))
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(ns l4-lp.web-editor.main
(ns l4-lp.web-editor.core
(:require [applied-science.js-interop :as jsi]
[hoplon.core :as h]
[hoplon.goog]
Expand Down
11 changes: 4 additions & 7 deletions src/l4_lp/web_editor/guifier.cljs
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
(ns l4-lp.web-editor.guifier
(ns l4-lp.web-editor.guifier
(:require [applied-science.js-interop :as jsi]
[l4-lp.swipl.js.wasm-query :as swipl-wasm-query]
[l4-lp.syntax.l4-to-prolog :as l4->prolog]
[promesa.core :as prom]
[shadow.esm :refer [dynamic-import]]))
["https://cdn.jsdelivr.net/npm/guifier@1.0.24/dist/Guifier.js"
:as guifier-mod]))

(def ^:private guifier
{:element-id "guifier"
:constructor
(prom/let
[cdn-url "https://cdn.jsdelivr.net/npm/guifier@1.0.24/dist/Guifier.js"
mod (dynamic-import cdn-url)]
(jsi/get mod :default))})
:constructor (jsi/get guifier-mod :default)})

(def ^:private query
(-> "query" l4->prolog/l4->prolog-str))
Expand Down