You don't get code out of the REPL. You evaluate your code inside the REPL, often directly from the source files.
For example I'll often write a function in a source file, evaluate it from there so it exists in the process, then call it from the REPL to test it works correctly.
When I launch the program, every temporaries made at the REPL are gone, but the source stays.
That is the workflow I currently use, too. Luckily, Leiningen reloads most of my changes. I wished, though, there was the ability to save the current name space from the REPL. Hacking together a couple of functions and save their definitions when you're happy.
That's inverted I think. For JVM clojure I am always editing inside a .clj file, all the scrap goes in (comment) forms in the file and I send forms to the repl from the file. I rarely actually type in the repl.
In a number of languages with a number of editors / editor plugins, with a code file open I can easily keep open in parallel a REPL window/tab that has the code file (and libs/pkgs/modules that it imports) loaded in interpreted mode and can reload either on save or if that isn't hooked up, certainly by a repl command like `:reload` in GHCi which I use in SublimeHaskell. Marvellous "live-coding" experience of sorts. Works particular well when writing pure functions (same in = same out, every time, no side-effects etc) and in a language where quickly defining some temp vars for passing some random test arguments in a swift non-verbose manner is a total non-issue
There are many editor plugins/configs which will allow you to evaluate code from inside your editor.
For instance, I use tmux/Vim/Vim Slime, which allows me to send code from the editor to the REPL (running in a separate tmux pane). This setup isn't as embedded or as fancy as some of the other options (e.g. Light Table). However, this setup doesn't force me to break my standard workflow and works with other languages which offer a repl or interactive console (e.g. Scheme/Racket, Ruby, Haskell, JS, etc.).