我一直在尝试使用Haskell来运行简单的生产流程。像许多生产过程一样,它涉及改变各地的事物状态。出于这个原因,我有一个脚本文件非常方便,我可以跟踪事物并有选择地将命令运行到交互式Haskell中,例如
if (!(operator.equals("*") || operator.equals("+") ...
如果您可以按下按钮将这些行发送到repl进程,那么如果像在R中使用ESS(Emacs说统计数据)那样真的很酷。也许是线条,段落,区域的单独按钮。有没有办法做到这一点?
例如,使用ESS,-- to start the process
process <- startProcess
-- to stop process
stopProcess
-- to check how things are going
summary <- checkStuff
summary
-- optionally restart bad processes
restartProcesses (getBadProcesses summary)
-- send summary emails
sendSummaryEmails summary ["abunch@ofemails.com", "thatIwould@rather.com",
"nothaveto@keep.com" "typing@out.com",
"orcopy@pasting.com"]
-- set up something big that I don't want to have to retype/paste every time
studentGrades <- getStudentGrades "John Peterson"
gen <- getStdGen
let (randomTest, gen') = generateRandomTest studentGrades gen
compilePdf randomTest
answers <- getAnswers
gradeTest randomTest answers "John Peterson"
发送一行,C-Ret
发送一个段落,C-c C-c
发送一个区域。
答案 0 :(得分:1)
此emacs lisp函数将向haskell的repl发送命令
(defun haskell-send-command (cmd)
(process-send-string (inferior-haskell-process) (concat cmd "\n")))
这将使用当前选择
调用前一个(defun haskell-send-selection ()
(interactive)
(haskell-send-command (x-selection)))
您可以使用global-set-key
为其指定键盘快捷键。然后,您需要弄清楚如何快速选择要发送的内容。例如M-h
是mark-paragraph。或者只是重新编码您喜欢的ESS功能:
(defun haskell-send-paragraph ()
(interactive)
(mark-paragraph)
(haskell-send-selection))
我实际上使用它们在emacs中为Haskell构建一个小的调试GUI。我有设置断点和步进的快捷方式,调试器的位置直接在haskell代码中突出显示。