haskell N00b : IntelliJ giving two errors

标签 haskell intellij-idea osx-mavericks

作为一名计算机科学专业的大三学生,我自己尝试在秋假期间临时抱佛脚学习 Haskell(对于我自己来说……不知道为什么我要折磨自己)。我下载了 IntelliJ 并安装了 Jetbrains 的官方 Haskell 插件。

我正在遵循“为伟大的利益而学习 Haskell!”的指示

编译此代码时:

test = putStrLn "Hello World!"

我收到此错误:

Information:Compilation completed with 2 errors and 1 warning in 2 sec
Information:2 errors
Information:1 warning
Error:cabal: build errors.
Warning:ghc: warning: control reaches end of non-void function [-Wreturn-type]
    int foo() {}
               ^
/Users/<USER_NAME>/Documents/Dropbox/Developer/IntelliJ/src/Main.hs
    Error:(1, 1) ghc: The function `main' is not defined in module `Main'

我在使用文本编辑器和终端时没有这个问题...但是我喜欢 IDE(对不起 VIM 伙计们)。另外,我正在运行 OS X 10.9,根据我的研究,已知它会导致问题。

最佳答案

您缺少 main 函数,就像错误告诉您的那样。只要有:

main :: IO ()
main = putStrLn "Hello World!"

或者:

test :: IO ()
test = putStrLn "Hello World!"

main :: IO ()
main = test

如果仍然给您带来问题,请在文件的开头添加:

module Main where

关于 haskell N00b : IntelliJ giving two errors,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26309446/

相关文章:

haskell - monads current "state of the art"是用纯语言做 IO 吗?

intellij-idea - "IDE has not been initialized yet"说 CLion/PyCharm/IntelliJ 无法启动

java - gradle/intellij - 共享测试资源

java - 在 Intellij IDEA 中使用 android.support.v4 库

windows - 操作 Hackage 中的源包如何轻松部署到多个 Windows 盒子?

用于模拟的 Haskell monad

Haskell 函数应用

运行两个命令时 Python 崩溃(段错误 : 11)

objective-c - 我的沙盒应用程序在 10.8 中运行良好,但在 10.9 中似乎用户默认值 .plist 根本没有保存

java - Mac OS X Mavericks 中的多个 Java 安装