<commit_before>---
layout: post
date: 2018-05-04
title: add-lib
---

This is a work-in-progress / sneak-peek of a new feature in [tools.deps.alpha](https://github.com/clojure/tools.deps.alpha) targeted at the problem of dynamically adding libraries while working at the REPL. For example, perhaps you're working along and discover a need to use custom memoization and want to use [core.memoize](https://github.com/clojure/core.memoize).

One option is to exit your repl, modify your deps.edn file and restart your repl. But wouldn't it be nice if you could do that dynamically? There are of course libraries that do dynamic library loading already and some that also give you isolation, but we were looking to give you something more integrated with deps.edn and tools.deps.alpha (so you can also take advantage of git deps, local deps, and whatever future kinds of deps are implemented).

As all the details of this feature are still in flux, we have not yet added it to tools.deps.alpha, but you can use a git dep from the branch to try it out if you like:

{% highlight shell %}
$ clj -Sdeps "{:deps \
               {org.clojure/tools.deps.alpha \ 
                {:git/url \"https://github.com/clojure/tools.deps.alpha.git\" \
                 :sha \"d492e97259c013ba401c5238842cd3445839d020\"}}}"
Cloning: https://github.com/clojure/tools.deps.alpha.git
Checking out: https://github.com/clojure/tools.deps.alpha.git 
at d492e97259c013ba401c5238842cd3445839d020
Clojure 1.9.0

user=> (use 'clojure.tools.deps.alpha.repl)
nil

user=> (add-lib 'org.clojure/core.memoize {:mvn/version "0.7.1"})
Downloading: org/clojure/core.memoize/0.7.1/core.memoize-0.7.1.pom
Downloading: org/clojure/core.cache/0.7.1/core.cache-0.7.1.pom
Downloading: org/clojure/data.priority-map/0.0.7/data.priority-map-0.0.7.pom
Downloading: org/clojure/core.memoize/0.7.1/core.memoize-0.7.1.jar
Downloading: org/clojure/core.cache/0.7.1/core.cache-0.7.1.jar
Downloading: org/clojure/data.priority-map/0.0.7/data.priority-map-0.0.7.jar
true<commit_msg>add link to clj getting started<commit_after>---
layout: post
date: 2018-05-04
title: add-lib
---

This is a work-in-progress / sneak-peek of a new feature in [tools.deps.alpha](https://github.com/clojure/tools.deps.alpha) targeted at the problem of dynamically adding libraries while working at the REPL. For example, perhaps you're working along and discover a need to use custom memoization and want to use [core.memoize](https://github.com/clojure/core.memoize).

One option is to exit your repl, modify your deps.edn file and restart your repl. But wouldn't it be nice if you could do that dynamically? There are of course libraries that do dynamic library loading already and some that also give you isolation, but we were looking to give you something more integrated with deps.edn and tools.deps.alpha (so you can also take advantage of git deps, local deps, and whatever future kinds of deps are implemented).

As all the details of this feature are still in flux, we have not yet added it to tools.deps.alpha, but you can use [clj](https://clojure.org/guides/getting_started) and a git dep from the branch to try it out if you like:

{% highlight shell %}
$ clj -Sdeps "{:deps \
               {org.clojure/tools.deps.alpha \ 
                {:git/url \"https://github.com/clojure/tools.deps.alpha.git\" \
                 :sha \"d492e97259c013ba401c5238842cd3445839d020\"}}}"
Cloning: https://github.com/clojure/tools.deps.alpha.git
Checking out: https://github.com/clojure/tools.deps.alpha.git 
at d492e97259c013ba401c5238842cd3445839d020
Clojure 1.9.0

user=> (use 'clojure.tools.deps.alpha.repl)
nil

user=> (add-lib 'org.clojure/core.memoize {:mvn/version "0.7.1"})
Downloading: org/clojure/core.memoize/0.7.1/core.memoize-0.7.1.pom
Downloading: org/clojure/core.cache/0.7.1/core.cache-0.7.1.pom
Downloading: org/clojure/data.priority-map/0.0.7/data.priority-map-0.0.7.pom
Downloading: org/clojure/core.memoize/0.7.1/core.memoize-0.7.1.jar
Downloading: org/clojure/core.cache/0.7.1/core.cache-0.7.1.jar
Downloading: org/clojure/data.priority-map/0.0.7/data.priority-map-0.0.7.jar
true
{'fraction_non_alphanumeric': 0.1187015503875969, 'fraction_numerical': 0.05426356589147287, 'mean_word_length': 3.708095781071836, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 11, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2106095', 'n_tokens_mistral': 1565, 'n_tokens_neox': 1448, 'n_words': 414}