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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With