【发布时间】:2019-10-13 09:54:24
【问题描述】:
在与之前的挫折中徘徊之后,我决定再次在 Emacs org-mode 中尝试 Haskell。我正在使用 Haskell stack-ghci (8.6.3)、Emacs 26.2、org-mode 9.2.3 设置 intero。这个代码块
#+begin_src haskell :results raw :session *haskell*
pyth2 :: Int -> [(Int, Int, Int)]
pyth2 n =
[ (x, y, z)
| x <- [1 .. n]
, y <- [x .. n]
, z <- [y .. n]
, x ^ 2 + y ^ 2 == z ^ 2
]
#+end_src
产生这个结果:
*Main| *Main| *Main| *Main| *Main|
<interactive>:59:16: error: Variable not in scope: n
<interactive>:60:16: error: Variable not in scope: n
<interactive>:61:16: error: Variable not in scope: n
但是,这个
#+begin_src haskell :results raw
tripleMe x = x + x + x
#+end_src
工作正常。我已将:set +m 添加到ghci.conf 和单个代码块中,但没有效果。此代码在单独的 REPL 中运行的单独 hs 文件中运行良好。单独文件中的pyth2 代码也可以从 org-mode 启动的 REPL 中调用,并且也可以正常运行。不知道如何进行。如有必要,可以包含 Emacs 初始化信息。
【问题讨论】:
-
我重写了
my-org-babel-execute-haskell-blocks函数。它现在可以正确处理声明中的模式匹配,并且对 cmets 也有一些支持。我不确定这个功能对你有多大用处,但如果你打算使用它,你一定要使用更新版本。
标签: emacs org-mode haskell-stack