repl
Jump to function (40) ›
- repl/apropos
- repl/build-facade
- repl/compile-str
- repl/create-ns
- repl/dir
- repl/doc
- repl/embed-ns
- repl/eval-capturing
- repl/eval-str
- repl/explain
- repl/explain-sym
- repl/find-fn
- repl/find-ns
- repl/fix
- repl/get-source-code
- repl/get-symbol-info
- repl/intern
- repl/load-file
- repl/loaded-namespaces
- repl/macroexpand
- repl/macroexpand-1
- repl/macroexpand-1-form
- repl/macroexpand-form
- repl/ns-aliases
- repl/ns-interns
- repl/ns-list
- repl/ns-publics
- repl/ns-refers
- repl/print-colorful
- repl/println-colorful
- repl/remove-ns
- repl/require
- repl/review
- repl/search-doc
- repl/search-ns
- repl/source
- repl/suggest
- repl/symbol-info
- repl/test-ns
- repl/use
repl/apropos#
(apropos search)
Returns a vector of symbols whose name contains the given search string. Searches across all loaded namespaces.
Example:
(apropos "map") ; => [phel.core/flat-map phel.core/map ...]
repl/build-facade#
repl/compile-str#
(compile-str s)
Compiles a Phel expression string to PHP code.
Example:
(compile-str "(+ 1 2)") ; => "(1 + 2)"
repl/create-ns#
(create-ns ns-str)
Creates the given namespace if it does not already exist. Returns the namespace name in display form. Existing namespaces are left untouched.
Example:
(create-ns "my-app.tmp") ; => "my-app.tmp"
repl/dir#
(dir ns)
Prints all public definitions in the given namespace symbol or string.
Returns nil. Prints one name per line, sorted alphabetically.
Example:
(dir phel\string)
repl/doc#
(doc sym)
Prints the documentation for the given symbol.
Example:
(doc map)
repl/embed-ns#
(embed-ns ns-str & [opts])
Builds a searchable index of public functions in a namespace.
Example:
(embed-ns "phel\core")
repl/eval-capturing#
(eval-capturing code-str)
Evaluates a string of Phel code while capturing stdout. Returns a hash-map with :value (the result), :out (captured stdout), :success (boolean), and :error (error message or nil).
Useful for nREPL and other tooling that needs to separate printed output from return values.
Example:
(eval-capturing "(do (println \"hello\") 42)") ; => {:value 42 :out "hello\n" :success true :error nil}
repl/eval-str#
(eval-str s)
Evaluates a string of Phel code and returns the result. If the string contains multiple expressions, returns the result of the last one.
Example:
(eval-str "(+ 1 2)") ; => 3
repl/explain#
(explain code-str)
Explains a Phel expression using AI and REPL introspection.
Example:
(explain "(map inc [1 2 3])")
repl/explain-sym#
(explain-sym sym)
Explains a symbol using AI with source code and docs as context.
Example:
(explain-sym map)
repl/find-fn#
(find-fn search)
Searches for functions whose name or docstring contains the search string. Returns a vector of maps with :ns, :name, :doc, :private, :min-arity, :max-arity, :is-variadic.
Example:
(find-fn "map") ; => [{:ns "phel.core" :name "map" ...} ...]
repl/find-ns#
(find-ns ns-str)
Returns the namespace name in display form if it is loaded, or nil if no namespace of that name exists. Accepts dot or backslash separators on input.
Example:
(find-ns "phel.core") ; => "phel.core"
repl/fix#
(fix code-str error-msg)
Suggests a fix for Phel code that produced an error.
Example:
(fix "(+ 1 \"a\")" "Cannot add string to integer")
repl/get-source-code#
(get-source-code ns-str name-str)
Returns the source code of the definition identified by namespace and name strings, or nil if the source file cannot be found or metadata is missing.
Example:
(get-source-code "phel\core" "map")
repl/get-symbol-info#
(get-symbol-info ns-str name-str)
Returns a hash-map of structured metadata for the definition identified by namespace and name strings. Returns nil if no such definition exists.
Keys: :doc, :file, :line, :column, :end-line, :end-column, :private, :deprecated, :min-arity, :max-arity, :is-variadic, :ns, :name
Example:
(get-symbol-info "phel\core" "map")
repl/intern#
(intern ns-str name-str & rest)
Finds or creates a definition named by name-str in namespace ns-str,
setting its root value to val when supplied (defaults to nil). The
namespace is auto-registered by the underlying addDefinition call.
Returns the fully qualified symbol (with the namespace in display form).
Example:
(intern "user" "x" 42) ; => user/x
repl/load-file#
(load-file path)
Loads and evaluates a Phel source file in the current REPL session. Reads the file content and evaluates it using the compiler, preserving the current REPL namespace context. Returns the result of the last expression.
Example:
(load-file "src/my-module.phel")
repl/loaded-namespaces#
(loaded-namespaces)
Returns all namespaces currently loaded in the REPL, in dot-separated display form.
Example:
(loaded-namespaces) ; => ["phel.core" "phel.repl"]
repl/macroexpand#
(macroexpand form)
Recursively expands the given form until it is no longer a macro call. The form must be quoted to prevent evaluation, matching Clojure semantics.
Example:
(macroexpand '(when true 1 2))
repl/macroexpand-1#
(macroexpand-1 form)
Expands the given form once if it is a macro call. The form must be quoted to prevent evaluation, matching Clojure semantics.
Example:
(macroexpand-1 '(when true 1 2))
repl/macroexpand-1-form#
(macroexpand-1-form form)
Expands the given form once if it is a macro call. Takes a quoted form and returns the expanded form, or the original form unchanged if it is not a macro call. Uses the CompilerFacade to perform the expansion without going through analyze+emit.
Example:
(macroexpand-1-form '(defn foo [x] x))
repl/macroexpand-form#
(macroexpand-form form)
Recursively expands the given form until it is no longer a macro call. Takes a quoted form and returns the fully expanded form. Uses the CompilerFacade to perform the expansion without going through analyze+emit.
Example:
(macroexpand-form '(defn foo [x] x))
repl/ns-aliases#
(ns-aliases ns-str)
Returns a hash-map of {alias => namespace} for all require aliases in the given namespace string. Target namespaces are returned in display form.
Example:
(ns-aliases *ns*) ; => {"repl" "phel.repl" ...}
repl/ns-interns#
(ns-interns ns-str)
Returns a hash-map of {name => value} for every definition in the given namespace, including private ones. Returns an empty map if the namespace has no definitions.
Example:
(ns-interns "phel\core")
repl/ns-list#
(ns-list)
Returns a sorted vector of all loaded namespace names in display form.
Example:
(ns-list) ; => ["phel.core" "phel.repl" ...]
repl/ns-publics#
(ns-publics ns-str)
Returns a hash-map of {name => value} for all public definitions in the given namespace string. Private definitions are excluded.
Example:
(ns-publics "phel\core") ; => {"map" <fn> "filter" <fn> ...}
repl/ns-refers#
(ns-refers ns-str)
Returns a hash-map of {name => source-namespace} for all referred symbols in the given namespace string. Source namespaces are returned in display form.
Example:
(ns-refers *ns*) ; => {"doc" "phel.repl" ...}
repl/print-colorful#
(print-colorful & xs)
Prints arguments with colored output.
Example:
(print-colorful [1 2 3])
repl/println-colorful#
(println-colorful & xs)
Prints arguments with colored output followed by a newline.
Example:
(println-colorful [1 2 3])
repl/remove-ns#
(remove-ns ns-str)
Removes the namespace and all of its definitions from the registry. Use with caution. Returns nil.
Example:
(remove-ns "my-app.tmp")
repl/require#
(require sym & args)
Requires a Phel module into the environment. Accepts both the flat form and the Clojure-compatible vector form: (require 'phel\string :as str) (require '[phel\string :as str]) (require '[phel\string :as str :refer [blank?]])
Example:
(require '[phel\string :as str]) ; => phel\string
repl/review#
(review code-str)
Gets an AI code review for Phel code.
Example:
(review "(defn add [a b] (+ a b))")
repl/search-doc#
(search-doc search)
Searches docstrings across all loaded namespaces for the given string. Prints matching function names and their documentation.
Example:
(search-doc "reduce")
repl/search-ns#
(search-ns query ns-index & [{:k k, :model model, :provider provider}])
Searches a namespace index for functions matching a query.
Example:
(search-ns "transform collections" my-ns-index 5)
repl/source#
(source sym)
Returns the source code of the given symbol as a string, or nil if unavailable.
Example:
(source map)
repl/suggest#
(suggest description)
Get AI-suggested Phel code for a natural language description.
Example:
(suggest "filter even numbers from a vector")
repl/symbol-info#
(symbol-info sym)
Returns a hash-map of structured metadata for the given symbol, or nil if the symbol cannot be resolved.
Keys: :doc, :file, :line, :column, :end-line, :end-column, :private, :deprecated, :min-arity, :max-arity, :is-variadic, :ns, :name
Example:
(symbol-info map) ; => {:doc "..." :ns "phel\core" :name "map" ...}
repl/test-ns#
(test-ns ns-str)
Runs all tests in a given namespace from the REPL. Requires the namespace if not already loaded, finds all deftest definitions, runs them, prints results, and returns a hash-map with :pass, :fail, and :error counts. Preserves outer test state so it can be safely called during a test run.
Example:
(test-ns "phel-test\test\core")
repl/use#
(use sym & args)
Adds a use statement to the environment.
Example:
(use DateTime :as DT) ; => DateTime