Ferdy
Ferdy

Reputation: 507

Arity of a function

Is there a way in clojurescript to check what the available arity implementations of a given cljs function are?

Upvotes: 4

Views: 410

Answers (2)

Rodrigo Taboada
Rodrigo Taboada

Reputation: 2727

If you're running Emacs with nREPL, as explained on this gist, when your text cursor is near the function name Emacs will show the signatures of the function in the message area.

Like that: emacs-screenshot

Upvotes: 1

Marcs
Marcs

Reputation: 3838

The only answer from Rodrigo Taboada is dated and now lots of new tools are out.

Light Table and Fighwheel

I think nowadays Light Table is one of the best tools for ClojureScript, especially when coupled with Figwheel. More info for using LT with Figwheel.

In Light Table to check a function signature you can simply put the cursor over the function name and hit Ctrl-D to toggle the inline documentation.

LT inline doc

Emacs and Cider + Figwheel

For Emacs Cider coupled with Figwheel is a great choice, interactive repl and debugger all inside Emacs.

For checking a function you can use the shortcut Ctrl-c d d to show the documentation and function signature.

emacs_cider_docs

Configure Cider cannot be easy at first but Figwheel makes the task easier, just un-comment the line under the comment ;; for CIDER in your project.clj file of your Figwheel project, like this:

:profiles {:dev {:dependencies [[binaryage/devtools "0.7.2"]
                                  [figwheel-sidecar "0.5.4-7"]
                                  [com.cemerick/piggieback "0.2.1"]]
                   ;; need to add dev source path here to get user.clj loaded
                   :source-paths ["src" "dev"]
                   ;; for CIDER
                   :plugins [[cider/cider-nrepl "0.13.0"]]
                   :repl-options {; for nREPL dev you really need to limit output
                                  :init (set! *print-length* 50)
                                  :nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}}}

Then set Cider to use figwheel as repl:

M-x then launch the command customize-variable, the variable name to customize is: cider-cljs-lein-repl then set the variable to Figwheel-sidecar, save the configuration state and you are done.

It is important that Cider is the same version of the cider-nrepl plugin, at the time of this post they HAVE to be both version 0.13.0.

Upvotes: 0

Related Questions