- Code: Select all
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
- Code: Select all
<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!