使用堆栈在 ghci 中加载一个新包 [英] Load a new package in ghci using stack

查看:36
本文介绍了使用堆栈在 ghci 中加载一个新包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Is there a way to load a package(s) using Stack in GHCI and play around with it ?

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

So, that when the ghci is loaded, we can import the modules and see it's type signature, etc.

推荐答案

对于 Stackage 中存在的包,

For the packages present in Stackage,

$ stack ghci --package unix-time

这会给你一个包含 unix-time 包的 repl:

And this will give you a repl with the package unix-time loaded in it:

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

这篇关于使用堆栈在 ghci 中加载一个新包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆