使用堆栈在ghci中加载新包

时间:2016-10-04 09:20:21

标签: haskell haskell-stack

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

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

1 个答案:

答案 0 :(得分:18)

对于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
λ>