我一直很想和Haskell和Scheme一起玩,所以我决定通过《 48小时内编写自己的方案》一书来进行探索。
我刚遇到第一个障碍,其中似乎缺少Monad
模块。我尝试在ghci
中运行它,结果似乎是相同的。
我的环境是OSX 10.15.2上的ghc 8.8.1。
% brew info ghc ghc: stable 8.8.1 (bottled), HEAD Glorious Glasgow
Haskell Compilation System https://haskell.org/ghc/
/usr/local/Cellar/ghc/8.8.1 (6,813 files, 1.5GB) *
以下是可复制的最小文件:
% cat hello.hs
module Main where
import Monad
import System.Environment
main :: IO ()
main = do
putStrLn ("Hello")
这是编译错误:
ghc hello.hs
[1 of 1] Compiling Main ( hello.hs, hello.o )
hello.hs:2:1: error:
Could not find module ‘Monad’
Use -v (or `:set -v` in ghci) to see a list of the files searched for.
|
2 | import Monad
| ^^^^^^^^^^^^
有任何提示吗?
亚历克斯
答案 0 :(得分:6)
您是要导入Control.Monad吗?
编译小型程序不需要任何导入,因为所需的一切已经通过Prelude模块隐式导入,但是您的整个程序比Prelude需要更多的依赖项。