Closed jstolarek closed 7 years ago
Note to self:
parseDesugarEval
and desugarEval
in Language.Slicer.Run
to return gammarunRepl
in REPL monad to allow passing initial state of the REPL (data decls + gamma + store)--repl
flag at the same time. When file passed parseDesugarEval
it and start repl setting the initial state to what was returned.I implemented all of the above (commit 373677c on branch js-slicing-h4x
) and it turns out not as simple as I thought it will be. The problematic part is that scopes are nested, so if I say:
let x = 5
in ...
then x
is not in scope after that expression has been desugared. The result is that when we load a file into a REPL we end up with an empty environment, so we can't refer to any top-level definitions inside a file. That's probably because we don't even have a concept of top level definitions.
Done. I found a much easier and much simpler way of doing this (~30 lines of code). You can now start a REPL by passing a list of REPL scripts to run during startup. Each file should contain single-line definitions (multi-line definitions are not allowed) declared with let bindings (so essentially, just as if you typed them into a REPL). See also #33 for a bug that allows to use program-style let bindings rather than repl-style let bindings.
I want to be able to load a file when starting a REPL. In theory haskeline has some kind of support for doing this but it didn't work out-of-the-box when I initially hacked the REPL. Need to investigate - this would be a very useful feature.