All Projects → vvvvalvalval → scope-capture-nrepl

vvvvalvalval / scope-capture-nrepl

Licence: MIT license
nREPL middleware for scope-capture

Programming Languages

clojure
4091 projects

Projects that are alternatives of or similar to scope-capture-nrepl

Scope Capture
Project your Clojure(Script) REPL into the same context as your code when it ran
Stars: ✭ 392 (+1351.85%)
Mutual labels:  tooling, repl
Figwheel Main
Figwheel Main provides tooling for developing ClojureScript applications
Stars: ✭ 514 (+1803.7%)
Mutual labels:  tooling, repl
Clj Suitable
ClojureScript "IntelliSense" support for JS objects and their properties/methods. Via figwheel and Emacs CIDER.
Stars: ✭ 82 (+203.7%)
Mutual labels:  tooling, repl
klisp
A Lisp written in about 200 lines of Ink, featuring an interactive literate programming notebook
Stars: ✭ 28 (+3.7%)
Mutual labels:  repl
concats
🔨 Desktop app to output a single-column csv file of rows of concatenated fields from an input csv or tsv file.
Stars: ✭ 20 (-25.93%)
Mutual labels:  tooling
quac
Quoine Exchange API Console
Stars: ✭ 14 (-48.15%)
Mutual labels:  repl
wcm-io-tooling
Tooling for Maven and IDEs.
Stars: ✭ 12 (-55.56%)
Mutual labels:  tooling
klipse-repl
Beginners friendly Clojure REPL
Stars: ✭ 44 (+62.96%)
Mutual labels:  repl
ol
Otus Lisp (Ol in short) is a purely* functional dialect of Lisp.
Stars: ✭ 157 (+481.48%)
Mutual labels:  repl
tinker-zero
Bridge laravel/tinker for your laravel-zero applications
Stars: ✭ 39 (+44.44%)
Mutual labels:  repl
hsx
Static HTML sites with JSX and webpack (no React).
Stars: ✭ 15 (-44.44%)
Mutual labels:  tooling
origami-build-tools
Standard Origami component development tools.
Stars: ✭ 49 (+81.48%)
Mutual labels:  tooling
java-sheets
☕ Run Java Snippets in your Browser
Stars: ✭ 19 (-29.63%)
Mutual labels:  repl
d3-fdg-svelte
d3 Force Directed Graph example (d3-force) implemented in sveltejs. REPL:
Stars: ✭ 31 (+14.81%)
Mutual labels:  repl
integrant-repl
Reloaded workflow functions for Integrant
Stars: ✭ 115 (+325.93%)
Mutual labels:  repl
solidity-shell
An interactive Solidity Shell
Stars: ✭ 434 (+1507.41%)
Mutual labels:  repl
Nota
A calculator with a beautiful interface for the Terminal, Including unicode-based charting and rich mathematical notation rendering
Stars: ✭ 45 (+66.67%)
Mutual labels:  repl
cicada
Cicada Language
Stars: ✭ 9 (-66.67%)
Mutual labels:  repl
robotframework-debuglibrary
A debug library for RobotFramework, which can be used as an interactive shell(REPL) also.
Stars: ✭ 96 (+255.56%)
Mutual labels:  repl
all-seeing-bot
Repl.it discord moderation bot
Stars: ✭ 73 (+170.37%)
Mutual labels:  repl

scope-capture-nrepl

Clojars Project

A companion library to scope-capture, providing an nREPL middleware that lets you put your REPL in the context of an Execution Point (via sc.api/letsc).

Project status: alpha quality. Tested empirically on Cursive. OTOH, this is typically only used in development, and for most purposes you can just falling back to using the raw API of scope-capture.

NOTE: this middleware is only suitable for programs where the REPL and the nREPL middleware run in the same process (typically JVM Clojure, typically not JVM-compiled ClojureScript.)

Installation

This library exposes an nREPL middleware in the Var sc.nrepl.middleware/wrap-letsc.

It works with both the nREPL library and the older tools.nrepl: you must provide these dependencies separately.

Via deps.edn

You need to declare dependencies both to this library and to nREPL itself. You'll typically want to put them in a custom profile, as recommended by the nREPL documentation:

;; in your deps.edn file:
{
 ;; [...]
 :aliases
 {
  ;; [...]
  :nREPL
  {:extra-deps
   {nrepl/nrepl {:mvn/version "0.5.3"}
    vvvvalvalval/scope-capture-nrepl {:mvn/version "0.3.1"}}}}}

Via Leiningen

Add the following to your project.clj file (potentially in a development profile):

  :dependencies 
  [... ;; you probably have other dependencies 
   [vvvvalvalval/scope-capture-nrepl "0.3.1"]]
  :repl-options
  {:nrepl-middleware
   [... ;; you may have other nREPL middleware 
    sc.nrepl.middleware/wrap-letsc]}

Usage

Assume you placed a sc.api/spy (or sc.api/brk) call in the following code:

(defn foo
  [x y]
  (let [z (* x y)]
    (sc.api/spy  
      (+ (* x x) (* 2 z) (* y y)))))
;SPY <-3> /home/me/myapp/src/myapp/myns.clj:4 
;  At Code Site -3, will save scope with locals [x y z]

You ran it and got an Execution Point with id 7:

(foo 2 23)
;SPY [7 -3] /home/me/myapp/src/myapp/myns.clj:4 
;  At Execution Point 7 of Code Site -3, saved scope with locals [x y z]
;SPY [7 -3] /home/me/myapp/src/myapp/myns.clj:4 
;(+ (* x x) (* 2 z) (* y y))
;=>
;625

You can now 'place yourself' in the context of that Execution Point by calling sc.nrepl.repl/in-ep

(sc.nrepl.repl/in-ep 7)

Once you've done that, you'll see that the locals bindings of the Execution Point are always in scope, although not via Global Vars:

x 
=> 2 

y 
=> 23

z
=> 26

(+ x z)
=> 28

This is achieved by wrapping each code expression to evaluate (via the 'eval' and 'load-file' nREPL ops) with (sc.api/letsc <<ep-id>> <<expr>>).

So the semantics are exactly those of sc.api/letsc, you just don't get the tedium of writing them manually.

Once you're done with that Execution Point, you put your REPL back in a normal state by using sc.nrepl.repl/exit:

(sc.nrepl.repl/exit)

License

Copyright © 2017 Valentin Waeselynck and contributors.

Distributed under the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].