我一直在尝试使用Haskell来运行一个简单的生产过程。像许多生产过程一样,它涉及到改变各地事物的状态。因此,拥有一个脚本文件对我来说非常方便,我可以在其中跟踪情况,并有选择地在交互式Haskell中运行命令,例如
-- 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"如果像R中的ESS (Emacs讲统计数据)一样,如果您可以按下按钮将这些行发送到repl进程,那将是非常酷的。可以将行、段、区域的按钮分开。已经有办法做到这一点了吗?
例如,对于ESS,C-Ret发送行,C-c C-c发送段落,C-c C-r发送区域。
发布于 2016-08-24 19:09:58
此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就是标记段落。或者只需对您喜欢的ESS函数进行重新编码:
(defun haskell-send-paragraph ()
(interactive)
(mark-paragraph)
(haskell-send-selection))实际上,我使用这些工具在emacs中为Haskell构建了一个小型的调试GUI。我有用于设置断点和单步执行的快捷方式,并且调试器的位置在haskell代码中直接突出显示。
https://stackoverflow.com/questions/39045965
复制相似问题