gpt4 book ai didi

haskell - 在 OPTIONS 杂注中设置导入路径

转载 作者:行者123 更新时间:2023-12-04 04:33:03 25 4
gpt4 key购买 nike

根据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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com