我有两个名为 SimpleJSON.hs 的 haskell 文件,另一个是 Main.hs
--File: SimpleJSON.hs
module SimpleJSON
(
JValue (..)
,getString
,getInt
,getDouble
,getBool
,getObject
,getArray
,isNull
) where
data JValue = JString String
| JNumber Double
| JBool Bool
| JNull
| JObject [(String, JValue)]
| JArray [JValue]
deriving (Eq, Ord, Show)
和
--File: Main.hs
module Main () where
import SimpleJSON
main = print (JObject [("foo", JNumber 1), ("bar", JBool False)])
所以在编译的时候
我在做
ghc -c SimpleJSON.hs
和
ghc simple Main.hs SimpleJSON.o
然后我收到错误
Main.hs:1:1: error:
The IO action ‘main’ is not exported by module ‘Main’
|
1 | module Main () where
| ^
如何解决这个编译错误?
最佳答案
应该
module Main where
或者
module Main (main) where
关于haskell - 模块 ‘main’ 未导出 IO 操作 ‘Main’,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53685213/