Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Racket REPL and Submodules

Tags:

emacs

racket

Is there an easy way for me to load a submodule in the current file in racket-mode in emacs?

For example if I have the following file

#lang racket

(define (foo x)
  x)

(module+ sub
  (define (bar x y)
    x))

and I hit f5 in racket-mode to start the repl then foo is available but bar is not.

like image 829
Max New Avatar asked Aug 24 '15 15:08

Max New


1 Answers

You can combine dynamic-enter! and quote-module-path to do this.

Given a repl interaction for the code above that you posted:

> (require racket/enter syntax/location)
> (dynamic-enter! (quote-module-path sub))
> bar
#<procedure:bar>

Alternatively, you could use dynamic-require/expose (the expose part allows you require things that are not provided), as done here.

like image 78
Leif Andersen Avatar answered Nov 20 '22 15:11

Leif Andersen