简体   繁体   English

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

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

I've long wanted to have a play with Haskell and Scheme so I decided to work through the book "Write yourself a Scheme in 48 Hours" to explore both.我一直想尝试使用 Haskell 和 Scheme,所以我决定通读“在 48 小时内为自己编写一个方案”一书来探索两者。

I just hit my first obstacle where the Monad module seems to be missing.我刚刚遇到了我的第一个障碍, Monad模块似乎丢失了。 I've tried running it in ghci and the result seems to be the same.我试过在ghci运行它,结果似乎是一样的。

My environment is ghc 8.8.1 on OSX 10.15.2.我的环境是 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) *

Here is the minimum reproducible file:这是最小的可重现文件:

% cat hello.hs
module Main where
import Monad
import System.Environment

main :: IO ()
main = do
  putStrLn ("Hello")

And here is the compilation error:这是编译错误:

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
  | ^^^^^^^^^^^^

Any hints?任何提示?

Alex亚历克斯

Did you mean to import Control.Monad?你的意思是导入 Control.Monad 吗?

None of the imports you have are needed to compile the minified program, since everything you need is already implicitly imported through the Prelude module, but maybe your whole program requires more dependencies than Prelude.编译缩小的程序不需要任何导入,因为您需要的一切都已经通过 Prelude 模块隐式导入,但也许您的整个程序需要比 Prelude 更多的依赖项。

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

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