根据GHC 8.4.3 flag reference , -i
标志是动态的,这意味着 it should be settable by an OPTIONS
pragma .
所以我尝试了以下方法:
.
├── Main.hs
└── imp
└── Imported.hs
imp/Imported.hs
的内容:module Imported (foo) where
foo :: String
foo = "Foo"
Main.hs
的内容:{-# OPTIONS_GHC -iimp #-}
import Imported (foo)
main :: IO ()
main = putStrLn foo
但是,如果我尝试运行
Main.hs
使用 runhaskell
,它提示 Imported
找不到:$ runhaskell -v Main.hs
...
Main.hs:2:1: error:
Could not find module ‘Imported’
Locations searched:
Imported.hs
Imported.lhs
Imported.hsig
Imported.lhsig
如何指定
-i
OPTIONS
中的标志语用?
最佳答案
这似乎是文档错误 fixed 的回归。在 2007 年,然后在 2014 年重新打破,当时在标志引用表中将一堆“静态”更改为“动态”。根据链接的错误报告,-i
标志不是完全动态的。可以是:set
在 GHCi 中,但不能在 OPTIONS_GHC
中指定线。
关于haskell - 在 OPTIONS 杂注中设置导入路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51682304/