haskell - 如何在 emacs - haskell 模式下运行 haskell 应用程序?

标签 haskell emacs haskell-platform haskell-mode

helloworld.hs 中的代码:

main = do
putStrLn "Hello, what's your name?"
name <- getLine
putStrLn ("Hey " ++ name ++ ", you rock!")

在终端中测试的应用程序:

optimight@optimight:~$ ghc --make helloworld
[1 of 1] Compiling Main ( helloworld.hs, helloworld.o )
Linking helloworld ...
optimight@optimight:~$ ./helloworld
Hello, what's your name?
John
Hey John, you rock!

在 emacs 中加载 helloworld.hs - haskell 主要模式:

GHCi, version 7.4.1: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> :load "/home/optimight/helloworld.hs"
[1 of 1] Compiling Main ( /home/optimight/helloworld.hs, interpreted )
Ok, modules loaded: Main.
*Main>

现在,如何(程序是什么?)在 emacs - haskell 模式环境中测试它?(我相信,当我使用 emacs - haskell 模式时,应该不需要切换到终端。)

最佳答案

要执行类似于在命令行上执行的操作,您需要在 ghci 中加载程序(您已完成),然后调用 main 方法(只需键入main 在提示符下)。

关于haskell - 如何在 emacs - haskell 模式下运行 haskell 应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11708440/

相关文章:

haskell - 将 haskell 平台更新到最新版本的最流畅方法是什么?

haskell - 我的 parsec 解析器可以写弃用消息吗?

haskell - 在 Haskell 中乱码

haskell - 我可以使用模板 haskell 来定义缺少的功能吗?

emacs - 如何在组织模式导出中按编号引用部分?

emacs - 检测 Emacs 中的当前主要模式(来自 Lisp)?

visual-studio - Emacs 作为 IDE : Handling a project directory?

haskell - 是否可以让 `-=` 使用文字?

haskell - hackage.haskell.org 文档约定的含义

启用分析的 Haskell 重新安装基础