A peer-to-peer stack for code collaboration
Remove 'documentation' from PrimFns.
Julian K. Arni2379eb89a1e3
diff --git a/docs/source/reference.rst b/docs/source/reference.rstindex f0d479c..5369e81 100644--- a/docs/source/reference.rst+++ b/docs/source/reference.rst@@ -662,11 +662,6 @@ retrieve the docstring as a value use ``doc`` instead.Prints documentation for all documented variables in scope.-``document``-~~~~~~~~~~~~--Used to add documentation to variables.-``is-test-env``~~~~~~~~~~~~~~~@@ -1044,14 +1039,14 @@ from the remote chain``(add-quit after-quit-state before-quit-eval)``~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-Adds a ':quit' command to 'before-quit-eval', which switches to-'after-quit-state' (and to the eval in that state)+Adds a ``:quit`` command to ``before-quit-eval``, which switches to+``after-quit-state`` (and to the eval in that state)``(add-send oeval)``~~~~~~~~~~~~~~~~~~~~-Add a :send special form that sends the contents of *input to the-chain*\ cur-chain+Add a ``:send`` special form that sends the contents of ``_input`` to+the chain ``_cur-chain````(load-chain url)``~~~~~~~~~~~~~~~~~~~~@@ -1072,7 +1067,7 @@ The pure prelude.``(store-exprs evalfn)``~~~~~~~~~~~~~~~~~~~~~~~~-Store each new evaluated expression in '_inputs'+Store each new evaluated expression in ``_inputs````(eval-fn-app state f arg cb)``~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~@@ -1117,5 +1112,5 @@ the next state.``(update-chain-ref chain-ref)``~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-Update a ref containing a chain with the new expressions from the remote-chain\ No newline at end of file+Update ``chain-ref`` containing a chain with the new expressions from+the remote chain\ No newline at end of filediff --git a/exe/ReferenceDoc.hs b/exe/ReferenceDoc.hsindex 0883cef..1312a3e 100644--- a/exe/ReferenceDoc.hs+++ b/exe/ReferenceDoc.hs@@ -96,7 +96,7 @@ main = dostructs = ["member?"]patterns = ["match-pat", "_", "/?", "/nil", "/cons", "/as", "non-linear-merge"]refs = ["ref", "read-ref", "write-ref", "modify-ref"]- docs = ["help", "doc", "doc!", "apropos!", "document", "is-test-env"]+ docs = ["help", "doc", "doc!", "apropos!", "is-test-env"]io =[ "print!", "get-line!", "load!", "read-file!", "read-code!", "send-code!"diff --git a/rad/chain.rad b/rad/chain.radindex c35ab68..8464bc3 100644--- a/rad/chain.rad+++ b/rad/chain.rad@@ -11,19 +11,17 @@(... [(@ :env) (@ ident) (@ :val)])))(def new-chain+ "Return an empty chain dictionary with the given url."(fn [url]{:state (pure-env):inputs []:url url:index 0}))-(document 'new-chain- '(("url" string))- "Return an empty chain dictionary with the given url.")-;; eval-in-chain(def eval-in-chain+ "Evaluates 'expr' in the 'chain' and returns a dict with the ':result' and the resulting ':chain'."(fn [expr chain](def chain-eval (view (.. (@ :state) (@var 'eval)) chain))(def x (chain-eval expr (lookup :state chain)))@@ -41,10 +39,6 @@{:chain new-chain:result result }))-(document 'eval-in-chain- '(("expr" any) ("chain" chain))- "Evaluates 'expr' in the 'chain' and returns a dict with the ':result' and the resulting ':chain'.")-(:test "eval-in-chain"[:setup(do (def empty-chain (new-chain ""))@@ -89,14 +83,11 @@;; update-chain-ref(def update-chain-ref+ "Update `chain-ref` containing a chain with the new expressions from the remote chain"(fn [chain-ref](modify-ref chain-ref update-chain):ok))-(document 'update-chain-ref- '(("chain" chain))- "Update a ref containing a chain with the new expressions from the remote chain")-(:test "update-chain-ref"[:setup(do@@ -112,30 +103,25 @@;; add-quit(def add-quit+ "Adds a `:quit` command to `before-quit-eval`, which switches to `after-quit-state` (and to the eval in that state)"(fn [after-quit-state before-quit-eval](fn [expr env](if (eq? expr :quit)(list :ok after-quit-state)(before-quit-eval expr env)))))-(document 'add-quit- '(("after-quit-state" dict) ("before-quit-eval" fn))- "Adds a ':quit' command to 'before-quit-eval', which switches to 'after-quit-state' (and to the eval in that state)")-;; store-exprs(def store-exprs+ "Store each new evaluated expression in `_inputs`"(fn [evalfn](fn [expr env](def env_ (over (@var '_inputs) (fn [x] (add-right expr x)) env))(evalfn expr env_ ))))-(document 'store-exprs- '(("eval" fn))- "Store each new evaluated expression in '_inputs'")-;; add-send(def add-send+ "Add a `:send` special form that sends the contents of `_input` to the chain `_cur-chain`"(fn [oeval](fn [expr env](if (eq? expr :send)@@ -146,10 +132,6 @@(list :ok env_))((store-exprs oeval) expr env)))))-(document 'add-send- '(("eval-fn" fn))- "Add a :send special form that sends the contents of _input to the chain _cur-chain")-;; enter-remote-chain(def enter-remote-chain"Make the eval behave as that of a remote chain. The second param is the env to return to after :quit."diff --git a/rad/crypto.rad b/rad/crypto.radindex 27a8728..412a224 100644--- a/rad/crypto.rad+++ b/rad/crypto.rad@@ -1,4 +1,5 @@(def sign-from-file!+ "Create a signed message using a key-pair stored in a file. The file should contain output as generated by `gen-key-pair!`."(fn [keys-file msg](def ks (read (read-file! keys-file)))(def sig (gen-signature! (lookup :private-key ks) msg))@@ -6,17 +7,9 @@:signature sig:key (lookup :public-key ks)}))-(document 'sign-from-file!- '(("keys-file" string)- ("msg" string))- "Create a signed message using a key-pair stored in a file. The file should contain output as generated by 'gen-key-pair!'.")-(def verify-signed-message+ "Verify the signature of a signed message."(fn [sig-msg](verify-signature (lookup :key sig-msg)(lookup :signature sig-msg)(lookup :message sig-msg))))--(document 'verify-signed-message- '(("sig-msg" signed-message))- "Verify the signature of a signed message.")diff --git a/rad/prelude.rad b/rad/prelude.radindex 906d48d..e56cc63 100644--- a/rad/prelude.rad+++ b/rad/prelude.rad@@ -17,6 +17,7 @@(load! "rad/prelude/util.rad")(def pure-prelude-files+ "List of files which together define the pure prelude."(list"rad/prelude/test.rad" ;; pure unless test env"rad/prelude/basic.rad"@@ -33,27 +34,17 @@"rad/prelude/util.rad"))-(document 'pure-prelude-files- '()- "List of files which together define the pure prelude.")-(def pure-prelude-code+ "The pure prelude."(read-many(apply string-append(map (fn [f] (read-file! f)) pure-prelude-files))))-(document 'pure-prelude-code- '()- "The pure prelude.")-(def send-prelude!+ "Send the pure prelude to a chain."(fn [chain-id](send! chain-id pure-prelude-code)))-(document 'send-prelude!- '(("chain-id" string))-"Send the pure prelude to a chain.")-(def _initial-prompt-text"Text used for greeting in the repl.""Welcome to radicle. Type (help) for help.")diff --git a/rad/prelude/basic.rad b/rad/prelude/basic.radindex c3841c1..097d408 100644--- a/rad/prelude/basic.rad+++ b/rad/prelude/basic.rad@@ -1,13 +1,10 @@;; or(def or+ "Returns 'arg1' if 'arg1' is not #f, otherwise returns 'arg2'"(fn [x y](if x x y)))-(document 'or- '(("arg1" any) ("arg2" any))- "Returns 'arg1' if 'arg1' is not #f, otherwise returns 'arg2'")-(:test "or"[ (or #t #t) ==> #t ][ (or #t #f) ==> #t ]@@ -39,13 +36,10 @@;; length(def length+ "Returns the length of 'list'."(fn [xs](foldr (fn [x acc] (+ acc 1)) 0 xs)))-(document 'length- '(("list" list))- "Returns the length of 'list'.")-(:test "length"[ (length (list)) ==> 0][ (length (list 2)) ==> 1]diff --git a/rad/prelude/dict.rad b/rad/prelude/dict.radindex f9b47aa..55cea75 100644--- a/rad/prelude/dict.rad+++ b/rad/prelude/dict.rad@@ -3,13 +3,10 @@;; dict-from-list(def dict-from-list+ "Creates a dictionary from a list of key-value pairs."(fn [xs](foldr (fn [kv acc] (insert (head kv) (head (tail kv)) acc)) (dict) xs)))-(document 'dict-from-list- '(("list" list))- "Creates a dictionary from a list of key-value pairs.")-(:test "dict-from-list"[ (dict-from-list (list (list :one 1) (list :two 2)))==> { :one 1 :two 2 } ])@@ -35,13 +32,11 @@);; rekey-(def rekey (fn [old-key new-key mp]- (def old-val (lookup old-key mp))- (delete old-key (insert new-key old-val mp))))--(document 'rekey- '(("old-key" any) ("new-key" any) ("dict" dict))- "Change the key from 'old-key' to 'new-key' in 'dict'. If 'new-key' already exists, it is overwritten.")+(def rekey+ "Change the key from 'old-key' to 'new-key' in 'dict'. If 'new-key' already exists, it is overwritten."+ (fn [old-key new-key mp]+ (def old-val (lookup old-key mp))+ (delete old-key (insert new-key old-val mp))))(:test "rekey"[ (rekey :a :b {:a 5}) ==> {:b 5} ])diff --git a/rad/prelude/lens.rad b/rad/prelude/lens.radindex 51b6f0f..cf64aab 100644--- a/rad/prelude/lens.rad+++ b/rad/prelude/lens.rad@@ -3,84 +3,61 @@;; make-lens(def make-lens+ "Makes a lens out of a getter and a setter."(fn [g s]{:getter g :setter s}))-(document 'make-lens- '(("getter" function) ("setter" function))- "Makes a lens out of a getter and a setter.")-;; view(def view+ "View a value through a lens."(fn [lens target]((lookup :getter lens) target)))-(document 'view- '(("lens" dict) ("target" any))- "View a value through a lens.")-;; set(def set+ "Set a value though a lens."(fn [lens new-view target]((lookup :setter lens) new-view target)))-(document 'set- '(("lens" dict) ("value" any) ("target" any))- "Set a value though a lens.")-;; id-lens(def id-lens+ "The identity lens."(make-lens(fn [target] target)(fn [new-view target] new-view)))-(document 'id-lens- '()- "The identity lens.")-;; ..(def ..+ "Compose two lenses."(fn [lens1 lens2](make-lens(fn [target] (view lens2 (view lens1 target)))(fn [new-view target] (set lens1 (set lens2 new-view (view lens1 target)) target)))))-(document '..- '(("lens1" dict) ("lens2" dict))- "Compose two lenses.")-;; ...-(def ... (fn [lenses] (foldr .. id-lens lenses)))--(document '...- '(("lenses" list))- "Compose multiple lenses.")+(def ...+ "Compose multiple lenses."+ (fn [lenses] (foldr .. id-lens lenses)));; over(def over+ "Modify a value through a lens."(fn [lens f target](set lens (f (view lens target)) target)))-(document 'over- '(("lens" dict) ("fn" function) ("target" any))- "Modify a value through a lens.")-;; @(def @+ "Returns a lens targetting keys of dicts."(fn [k](make-lens (fn [mp] (lookup k mp))(fn [v mp] (insert k v mp)))))-(document '@- '(("key" any))- " Returns a lens targetting keys of dicts.")-(:test "view lens"[ (view (@ :one) {:one 1 :two 2}) ==> 1 ])@@ -123,26 +100,20 @@;; view-ref(def view-ref+ "Like 'view', but for refs."(fn [r lens](view lens (read-ref r))))-(document 'view-ref- '(("ref" ref) ("lens" dict))- "Like 'view', but for refs.")-(:test "view-ref"[ (view-ref (ref {:key 1}) (@ :key)) ==> 1 ]);; set-ref(def set-ref+ "Like 'set', but for refs."(fn [r lens v](modify-ref r (fn [x] (set lens v x)))))-(document 'set-ref- '(("ref" ref) ("lens" dict) ("new-value" any))- "Like 'set', but for refs.")-(:test "set-ref"[ ((fn [r](set-ref r (@ :a) 2)@@ -153,13 +124,10 @@;; over-ref(def over-ref+ "Like 'over', but for refs."(fn [r lens f](modify-ref r (fn [x] (over lens f x)))))-(document 'over-ref- '(("ref" ref) ("lens" dict) ("fn" function))- "Like 'over', but for refs.")-(:test "over-ref"[ ((fn [r](over-ref r (@ :a) (fn [x] (* x 2)))diff --git a/rad/prelude/list.rad b/rad/prelude/list.radindex 5d5915d..9add853 100644--- a/rad/prelude/list.rad+++ b/rad/prelude/list.rad@@ -6,11 +6,9 @@;; empty?-(def empty? (fn [ls] (or (eq? ls nil) (eq? ls []))))--(document 'empty?- '(("seq" sequence))- "True if 'seq' is empty, false otherwise.")+(def empty?+ "True if 'seq' is empty, false otherwise."+ (fn [ls] (or (eq? ls nil) (eq? ls []))))(:test "empty"[ (empty? (list 2)) ==> #f ]@@ -20,18 +18,15 @@;; reverse-(def reverse (fn [ls]- (def go (Y2 (fn [go]- (fn [acc new]- (if (empty? new)- acc- (go (cons (head new) acc) (tail new)))))))- (go (list) ls)))--(document 'reverse- '(("list" list))- "Returns the reversed 'list'.")-+(def reverse+ "Returns the reversed 'list'."+ (fn [ls]+ (def go (Y2 (fn [go]+ (fn [acc new]+ (if (empty? new)+ acc+ (go (cons (head new) acc) (tail new)))))))+ (go (list) ls)))(:test "reverse"[ (reverse (list 1 2 3)) ==> (3 2 1) ]@@ -39,14 +34,12 @@;; range-(def range (Y2 (fn [range] (fn [from to]- (if (eq? from to)- (list to)- (cons from (range (+ 1 from) to)))))))--(document 'range- '(("start" number) ("end" number))- "Returns a list with all integers from 'start' to 'end', inclusive.")+(def range+ "Returns a list with all integers from 'start' to 'end', inclusive."+ (Y2 (fn [range] (fn [from to]+ (if (eq? from to)+ (list to)+ (cons from (range (+ 1 from) to)))))))(:test "range"[ (range 1 5) ==> (1 2 3 4 5) ]@@ -54,12 +47,10 @@;; concat-(def concat (fn [list1 list2]- (foldr (fn [a b] (cons a b)) list2 list1)))--(document 'concat- '(("list1" list) ("list2" list))- "Concatenates 'list1' and 'list2'.")+(def concat+ "Concatenates 'list1' and 'list2'."+ (fn [list1 list2]+ (foldr (fn [a b] (cons a b)) list2 list1)))(:test "concat"[ (concat '(1 2 3) '(4 5 6)) ==> (1 2 3 4 5 6) ]@@ -67,16 +58,14 @@;; filter-(def filter (Y2 (fn [filter] (fn [pred ls]- (if (empty? ls)- ls- (if (pred (head ls))- (cons (head ls) (filter pred (tail ls)))- (filter pred (tail ls))))))))--(document 'filter- '(("filter-cond" function) ("list" list))- "Returns 'list' with only the elements that satisfy 'filter-cond'.")+(def filter+ "Returns 'list' with only the elements that satisfy 'filter-cond'."+ (Y2 (fn [filter] (fn [pred ls]+ (if (empty? ls)+ ls+ (if (pred (head ls))+ (cons (head ls) (filter pred (tail ls)))+ (filter pred (tail ls))))))))(:test "filter"[ (filter (fn [x] (< x 10)) (list 3 10 11))diff --git a/rad/prelude/ref.rad b/rad/prelude/ref.radindex e58045a..5ab3f07 100644--- a/rad/prelude/ref.rad+++ b/rad/prelude/ref.rad@@ -2,9 +2,6 @@;; modify-ref(def modify-ref+ "Modify 'ref' by applying the provided function. Returns the new value."(fn [r f](write-ref r (f (read-ref r)))))--(document 'modify-ref- '(("ref" ref) ("fn" function))- "Modify 'ref' by applying the provided function. Returns the new value.")diff --git a/src/Radicle/Internal/PrimFns.hs b/src/Radicle/Internal/PrimFns.hsindex a511287..3a65fe8 100644--- a/src/Radicle/Internal/PrimFns.hs+++ b/src/Radicle/Internal/PrimFns.hs@@ -517,16 +517,6 @@ purePrimFns = fromList $ allDocs $String t -> pure . Boolean . UUID.isUUID $ tv -> throwErrorHere $ TypeError "uuid?" 0 TString v)- , ( "document"- , "Used to add documentation to variables."- , \case- [Atom i, List _, String desc] -> do- v <- lookupAtom i- defineAtom i (Just desc) v- pure nil- [_,_,_] -> throwErrorHere $ OtherError "document: expects an atom, a list of argument docs, and a string."- xs -> throwErrorHere $ WrongNumberOfArgs "document" 3 (length xs)- ), ( "doc", "Returns the documentation string for a variable. To print it instead, use `doc!`.", oneArg "doc" $ \case