# How do I create a functional REPL?

**URL:** <https://racket.discourse.group/t/how-do-i-create-a-functional-repl/154>\
**Category:** Questions & Answers\
**Created:** [November 18, 2021, 3:12pm UTC](https://racket.discourse.group/t/how-do-i-create-a-functional-repl/154 "2021-11-18T15:12:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![benknoble](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/benknoble/32/16_2.png) [@benknoble](https://racket.discourse.group/u/benknoble)\
**Post date:** [November 18, 2021, 3:12pm UTC](https://racket.discourse.group/t/how-do-i-create-a-functional-repl/154/1 "2021-11-18T15:12:18Z")

</div>

I know I can use `(read-eval-print-loop)`, but by default it has no `#%top-interaction` or `#%app` or anything.

I would also like to be able to augment it with specific bindings.

---

<div class="post-metadata">

**Author:** ![benknoble](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/benknoble/32/16_2.png) [@benknoble](https://racket.discourse.group/u/benknoble)\
**Post date:** [November 18, 2021, 3:14pm UTC](https://racket.discourse.group/t/how-do-i-create-a-functional-repl/154/2 "2021-11-18T15:14:10Z")

</div>

You need to set the `current-namespace`: by default, this parameter is unconnected to any code.

The template is

```
(parameterize ([current-namespace N])
  (read-eval-print-loop))

```

A reasonable value for `N` is `(make-base-namespace)`, which is like using `racket/base` for all initial bindings.

If you want to augment bindings, you can

```
(define-namespace-anchor this-module)

```

and use `(namespace-anchor->namespace this-module)` as `N`. Then any bindings in the current module (including those provided by `require`s) are available in the REPL.

---

<div class="post-metadata">

**Author:** ![greghendershott](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/greghendershott/32/98_2.png) [@greghendershott](https://racket.discourse.group/u/greghendershott)\
**Post date:** [November 18, 2021, 6:21pm UTC](https://racket.discourse.group/t/how-do-i-create-a-functional-repl/154/3 "2021-11-18T18:21:00Z")

</div>

`module->namespace` is another reasonable value. It gives you bindings inside any arbitrary module. The REPL in tools like Dr Racket, xrepl, and Racket Mode is, as a starting point, `(parameterize ([current-namespace (module->namespace mod-path)]) (read-eval-print-loop))`.
