繁体   English   中英

ghc 抱怨“找不到模块‘Monad’”

[英]ghc complains "Could not find module ‘Monad’"

我一直想尝试使用 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
  | ^^^^^^^^^^^^

任何提示?

亚历克斯

你的意思是导入 Control.Monad 吗?

编译缩小的程序不需要任何导入,因为您需要的一切都已经通过 Prelude 模块隐式导入,但也许您的整个程序需要比 Prelude 更多的依赖项。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM