Saw this function in the changelog for the latest beta and couldn’t find any examples yet on how to use it yet, so I played around a little:
class GhcExpressionCommand(sublimeplugin.TextCommand):
def run(self, view, args):
view.window().runCommand("save")
runexpr = lambda e: view.window().runCommand("exec","","ghc.exe -e \"" + e.replace("\"","\\\"") + "\" \"" + view.fileName() + "\""])
view.window().showInputPanel("Run Ghc expression:", "", runexpr, lambda s:s, 0)
Bind with something like
<binding key="F8" command="ghcExpression">
<context name="selector" value="source.haskell"/>
</binding>
and voila, an interactive Haskell prompt in Sublime text. Useful for things like checking types or quickly testing the output of a function.
It should work for other languages as well, assuming they can run commands on a file from the command line.
Very useful addition, thanks jps!