jstolarek / slicer

Companion code for paper "Imperative Functional Programs that Explain their Work", Wilmer Ricciotti, Jan Stolarek, Roly Perera and James Cheney, ICFP 2017, Oxford, UK
http://dl.acm.org/citation.cfm?id=3110258
GNU General Public License v3.0
6 stars 0 forks source link

Load files into REPL #19

Closed jstolarek closed 7 years ago

jstolarek commented 7 years ago

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.

jstolarek commented 7 years ago

Note to self:

jstolarek commented 7 years ago

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.

jstolarek commented 7 years ago

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.