gpt4 book ai didi

haskell - 使用堆栈在 ghci 中加载新包

转载 作者:行者123 更新时间:2023-12-02 11:49:18 26 4
gpt4 key购买 nike

有没有办法在 GHCI 中使用 Stack 加载包并使用它?

因此,当加载 ghci 时,我们可以导入模块并查看它的类型签名等。

最佳答案

对于 Stackage 中存在的包,

$ stack ghci --package unix-time

这将为您提供一个包含 unix-time 包的 repl:

Run from outside a project, using implicit global project config
Using resolver: lts-6.14 from implicit global project's config file: /home/sibi/.stack/global-project/stack.yaml
GHCi, version 7.10.3: http://www.haskell.org/ghc/ :? for help
λ> import Data.UnixTime
λ> :t getUnixTime
getUnixTime :: IO UnixTime

对于多个包:

$ stack ghci --package unix-time --package download
Run from outside a project, using implicit global project config
Using resolver: lts-6.14 from implicit global project's config file: /home/sibi/.stack/global-project/stack.yaml
tagsoup-0.13.10: using precompiled package
xml-1.3.14: using precompiled package
time-locale-compat-0.1.1.3: using precompiled package
feed-0.3.11.1: download
feed-0.3.11.1: configure
feed-0.3.11.1: build
feed-0.3.11.1: copy/register
download-0.3.2.4: download
download-0.3.2.4: configure
download-0.3.2.4: build
download-0.3.2.4: copy/register
Completed 5 action(s).
Configuring GHCi with the following packages:
GHCi, version 7.10.3: http://www.haskell.org/ghc/ :? for help
Ok, modules loaded: none.
λ> import Network.Download
λ>

关于haskell - 使用堆栈在 ghci 中加载新包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39848576/

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