doc! works!

This commit is contained in:
Scott Richmond 2024-06-04 13:28:20 -04:00
parent 478bc8649e
commit 4da846d8d7
2 changed files with 17 additions and 6 deletions

View File

@ -80,7 +80,13 @@
:string (get-in x [:token :lexeme])
(error (string "cannot show pattern of unknown type " (x :type)))))
(defn- docstring [fnn] :todo)
(defn doc! [fnn]
(def {:name name :doc doc :body clauses} fnn)
(print "doccing " name)
(def patterns (map (fn [x] (-> x first show-patt)) clauses))
(print name)
(print (string/join patterns " "))
(print doc))
(defn- conj-set [sett value]
(def new (merge sett))
@ -125,6 +131,9 @@
:set (-> x (dissoc :^type) keys)
@[x]))
(defn print! [& args]
(print ;(map show args)))
(defn prn [x]
(pp x)
x)
@ -140,7 +149,7 @@
(defn set! [x] (set (x :value) x))
(def ctx {
"print" print
"print!" print!
"prn" prn
"eq" deep=
"bool" bool
@ -161,6 +170,7 @@
"type" ludus/type
"stringify" stringify
"show" show
"doc!" doc!
"concat" concat
"conj" conj
"disj" disj
@ -194,7 +204,6 @@
Used in current prelude but not yet in base:
into/2
doc
to_dict
)

View File

@ -554,7 +554,7 @@
# (def cleaned (get-in parsed [:ast :data 1]))
# (pp cleaned)
# (interpret (parsed :ast) @{:^parent b/ctx})
(try (interpret (parsed :ast) @{})
(try (interpret (parsed :ast) @{:^parent b/ctx})
([e] (print "Ludus panicked!: "
(if (struct? e) (error (e :msg)) (error e)))))
)
@ -562,12 +562,14 @@
(do
(set source `
fn foo {
"a foo, a bar"
"a doc, another doc"
() -> :foo
(_) -> :bar
}
doc! (foo)
`)
(def result (run))
# (b/show result)
(b/show result)
)