haskell - ghc 抱怨“找不到模块‘Monad’”
问题描述
我一直想玩 Haskell 和 Scheme,所以我决定通读《在 48 小时内为自己编写一个 Scheme》一书来探索这两者。
我刚刚遇到了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 更多的依赖项。
推荐阅读
- python - 从python中的文本文件打印特定行
- sql - 视图中的 SQL 更新表
- ldap - OpenLDAP 搜索过滤器 DN 语法错误 (34) 身份验证失败
- python - 如何将所有 .txt 文件加载到具有不同名称的文件夹中 - Python
- electron - 我在哪里可以看到电子生成器自定义 NSIS 包含脚本中的回声输出?
- html - 使用 Golang 在特定打印机上打印 HTML
- reactjs - 内联使用情绪反应主题颜色
- javascript - 如何使用 formdata reactjs 发布图像数组
- http - 尽管 WriteHeader 用于返回另一个状态代码,但返回 200 状态代码
- ios - iOS SystemConfiguration plist - 更改HTTP代理不生效