Tolk is an interpreter that can interpret Clojure data strutures and return whataever you define. It's purpose is to take away boilerplate code when interpreting or transforming data structures.
Tolk is an interpreter that can interpret Clojure data strutures and return whataever you define. It's purpose is to take away boilerplate code when interpreting or transforming data structures.
(comp-interpreters & interpreters)
Composes interpreters in a similar way as clojure.core/comp
. Returns a
chained interpreter.
If there is an error anywhere in the interpreter chain, the interpretation chain is stopped and the error is returned.
Composes interpreters in a similar way as `clojure.core/comp`. Returns a chained interpreter. If there is an error anywhere in the interpreter chain, the interpretation chain is stopped and the error is returned.
(error? x)
Test whether the interpreted result is an error
Test whether the interpreted result is an error
(get! res)
Forces the value of an interpreted result. If an error occurred during interpretation, and exception will be thrown.
Forces the value of an interpreted result. If an error occurred during interpretation, and exception will be thrown.
(interpret resolve-var expr)
(interpret resolve-var expr opts)
Interprets the specified expr
by creating and running an interpreter
.
See interpreter
for available options
Interprets the specified `expr` by creating and running an `interpreter`. See `interpreter` for available options
(interpreter resolve-var)
(interpreter resolve-var opts)
Returns a function that can interpret an arbitrary form. Useful for interpreting the same form in multiple different ways. The returned intepret function interprets an expression and returns a map with either :tolk/result or :tolk/error key and corresponding data.
resolve-var
is an ifn that takes x and returns the function represented
by x, which means that resolve-var
can be a function or map. To use an entire
namespace, the result of (ns-publics 'some.ns)
can be passed as resolve-var
opts
is a map which can contains one of the following keys:
The README, tests and examples are the best way to see different usages, but here is a small example of a happy case. Given the expression:
(def expr '(plus (minus 8 2) 5))
we can make an interpreted calculator:
(let [calculate (interpreter {'plus + 'minus -})]
(calculate expr))
; => {:tolk/result 11}
Returns a function that can interpret an arbitrary form. Useful for interpreting the same form in multiple different ways. The returned intepret function interprets an expression and returns a map with either :tolk/result or :tolk/error key and corresponding data. `resolve-var` is an ifn that takes x and returns the function represented by x, which means that `resolve-var` can be a function or map. To use an entire namespace, the result of `(ns-publics 'some.ns)` can be passed as `resolve-var` `opts` is a map which can contains one of the following keys: * ` The README, tests and examples are the best way to see different usages, but here is a small example of a happy case. Given the expression: ``` (def expr '(plus (minus 8 2) 5)) ``` we can make an interpreted calculator: ``` (let [calculate (interpreter {'plus + 'minus -})] (calculate expr)) ; => {:tolk/result 11} ```
Test whether the interpreted result is a success
Test whether the interpreted result is a success
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close