我经常使用ghci它进行少量计算并stack ghci处理我的实际项目。
为了使第一个更容易,我编写了一个.ghci包含许多导入模块的文件,但其中一些模块不存在于我的堆栈项目中,并且我遇到了严重的错误。
目前我使用别名stackghci="stack ghci --ghci-options -ignore-dot-ghci",但随后我再次出现默认提示等等。
有没有办法指定两个.ghci文件;一个用于堆栈,一个用于ghci?
操作系统:openSUSE Tumbleweed 最新
正如堆栈文档所说,我可以使用 Tumbleweed 上默认存储库中的 zypper 安装堆栈。到 bin 的路径是/usr/bin/stack。
我遵循官方主页上的堆栈教程并执行stack new helloworld new-template(有效)。后cd进入文件夹,我想跑stack setup,但是这一次失败:
The GHC located at /usr/bin/ghc failed to compile a sanity check. Please see:
http://docs.haskellstack.org/en/stable/install_and_upgrade/
for more information. Exception was:
Running /usr/bin/ghc /tmp/stack-sanity-check9034/Main.hs
-no-user-package-db in directory /tmp/stack-sanity-check9034/
exited with ExitFailure 1
/tmp/stack-sanity-check9034/Main.hs:1:8:
Could not find module ‘Distribution.Simple’
Use -v to see a list of the files searched for.
Run Code Online (Sandbox Code Playgroud)
经过一番谷歌搜索后,我仍然不知道如何解决该错误。这就像我错过了一个非常基本的东西。
您好我尝试使用堆栈为yesod创建一个新的proyect,按照快速入门教程; 创建脚手架我使用命令:
stack new my-project yesod-postgres && cd my-project
Run Code Online (Sandbox Code Playgroud)
但是当跑步时stack exec -- yesod devel得到:
cabal: At least the following dependencies are missing:
classy-prelude >=0.10.2,
classy-prelude-conduit >=0.10.2,
classy-prelude-yesod >=0.10.2,
data-default -any,
hjsmin >=0.1 && <0.3,
monad-logger ==0.3.*,
persistent >=2.0 && <2.6,
persistent-postgresql >=2.1.1 && <2.6,
persistent-template >=2.0 && <2.6,
safe -any,
yesod >=1.4.3 && <1.5,
yesod-auth >=1.4.0 && <1.5,
yesod-core >=1.4.17 && <1.5,
yesod-form >=1.4.0 && <1.5,
yesod-static >=1.4.0.3 && <1.6
Run Code Online (Sandbox Code Playgroud)
我尝试使用该命令stack exec -- cabal install …
我正在使用堆栈ghci版本8在Ubuntu 16.04上工作.我想在Haskell中导入System.Random,但似乎我遇到麻烦,可能涉及Cabal.我在这个网站上看到了类似的帖子,但他们通常说这是因为版本较旧,但我使用的是版本8.
我收到错误:
Failed to load interface for ‘System.Random’
Use -v to see a list of the files searched for.
Run Code Online (Sandbox Code Playgroud)
这告诉我我有System.Random的问题.在网上看,我发现我需要先安装Cabal.
当我输入
Cabal --version
Run Code Online (Sandbox Code Playgroud)
我明白了
cabal-install version 1.22.6.0
using version 1.22.5.0 of the Cabal library
Run Code Online (Sandbox Code Playgroud)
这告诉我,我已经拥有它.所以当我尝试更新时
sudo apt-get install cabal-install cabal update
Run Code Online (Sandbox Code Playgroud)
我明白了
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package cabal
E: Unable to locate package update
Run Code Online (Sandbox Code Playgroud)
这很奇怪.如果我忽略它并尝试随机安装随机
cabal install random
Run Code Online (Sandbox Code Playgroud)
我明白了
Resolving dependencies...
All the requested packages are already installed: …Run Code Online (Sandbox Code Playgroud) 我需要将x11 包与lts-8.2 解析器一起使用,当我运行命令时stack build,我得到以下信息:
X11-1.8: configure
Progress: 1/2
-- While building package X11-1.8 using:
/tmp/stack7885/X11-1.8/.stack-work/dist/x86_64-linux/Cabal-1.24.2.0 /setup/setup --builddir=.stack-work/dist/x86_64-linux/Cabal-1.24.2.0 configure --with-ghc=/home/userXYZ/.stack/programs/x86_64-linux/ghc-8.0.2/bin/ghc --with-ghc-pkg=/home/userXYZ/.stack/programs/x86_64-linux/ghc-8.0.2/bin/ghc-pkg --user --package-db=clear --package-db=global --package-db=/home/userXYZ/.stack/snapshots/x86_64-linux/lts-8.2/8.0.2/pkgdb --libdir=/home/userXYZ/.stack/snapshots/x86_64-linux/lts-8.2/8.0.2/lib --bindir=/home/userXYZ/.stack/snapshots/x86_64-linux/lts-8.2/8.0.2/bin --datadir=/home/userXYZ/.stack/snapshots/x86_64-linux/lts-8.2/8.0.2/share --libexecdir=/home/userXYZ/.stack/snapshots/x86_64-linux/lts-8.2/8.0.2/libexec --sysconfdir=/home/userXYZ/.stack/snapshots/x86_64-linux/lts-8.2/8.0.2/etc --docdir=/home/userXYZ/.stack/snapshots/x86_64-linux/lts-8.2/8.0.2/doc/X11-1.8 --htmldir=/home/userXYZ/.stack/snapshots/x86_64-linux/lts-8.2/8.0.2/doc/X11-1.8 --haddockdir=/home/userXYZ/.stack/snapshots/x86_64-linux/lts-8.2/8.0.2/doc/X11-1.8 --dependency=base=base-4.9.1.0 --dependency=data-default=data-default-0.7.1.1-7EGYJX2YWqWJRbPFUHNoCr
Process exited with code: ExitFailure 1
Logs have been written to: /home/userXYZ/Documents/programming/haskell/projects/MyStack/screen-linux/.stack-work/logs/X11-1.8.log
[1 of 1] Compiling Main ( /tmp/stack7885/X11-1.8/Setup.hs, /tmp/stack7885/X11-1.8/.stack-work/dist/x86_64-linux/Cabal-1.24.2.0/setup/Main.o )
/tmp/stack7885/X11-1.8/Setup.hs:6:29: warning: [-Wdeprecations]
In the use of ‘defaultUserHooks’
(imported from Distribution.Simple):
Deprecated: "Use simpleUserHooks or autoconfUserHooks, unless you need …Run Code Online (Sandbox Code Playgroud) 所以我尝试安装ghc-mod-5.4.0.0,它与其他一些安装一起崩溃:
Error: While constructing the build plan, the following exceptions were encountered:
In the dependencies for ghc-mod-5.4.0.0:
async-2.1.1 must match <2.1 && >=2.0.2 (latest applicable is 2.0.2)
cabal-helper-0.7.3.0 must match <0.7 && >=0.6.1.0 (latest applicable is 0.6.3.1)
cereal-0.5.4.0 must match <0.5 && >=0.4 (latest applicable is 0.4.1.1)
directory-1.3.0.0 must match <1.3 (latest applicable is 1.2.7.1)
extra-1.5.1 must match ==1.4.* (latest applicable is 1.4.12)
ghc-8.0.2 must match >=7.4 && <7.11
haskell-src-exts-1.18.2 must match <1.18 && >=1.16.0.1 (latest applicable is …Run Code Online (Sandbox Code Playgroud) 是否stack仅在需要时为其他人编译和链接整个项目stack ghci?
它不应该跳过前者并立即跳转到ghci加载源吗?我已经观察到它在我的大多数项目中都为我做,因此它正在做看似多余的工作。这是设计使然,还是我的某些堆栈项目配置错误?
也许这是cabal在没有stack要求的情况下由底层完成的?
无论如何,当我只想输入时,我可以做些什么来跳过编译+链接stack ghci?
您好,我尝试将Haskell与vscode一起使用,如果我尝试在另一个模块中使用模块,则会出现以下错误:
Failed to load interface for **Client**
Use -v to see a list of the files searched for.
Run Code Online (Sandbox Code Playgroud)
第一个模块:
module Main where
import qualified Client as Cl
main ::IO ()
main = do
name<- getLine
sp
Run Code Online (Sandbox Code Playgroud)
第二个模块:
module Client
(sp)where
sp::IO()
sp=print "SecondModule"
Run Code Online (Sandbox Code Playgroud)
经过一番阅读后,我尝试更新堆栈并安装构建工具,此时出现以下错误:
$ stack install gtk2hs-buildtools
?[0mprimitive-0.6.3.0: using precompiled package?[0m
?[0mCabal-2.0.1.1: using precompiled package?[0m
?[0mmtl-2.2.1: using precompiled package?[0m
?[0mrandom-1.1: using precompiled package?[0m
?[0mtext-1.2.2.2: using precompiled package?[0m
?[0mvector-0.12.0.1: using precompiled package?[0m
?[0mtf-random-0.5: configure?[0m
?[0mhashable-1.2.6.1: using precompiled package?[0m
?[0mhappy-1.19.9: download?[0m …Run Code Online (Sandbox Code Playgroud) 创建新的Stack项目时,可执行文件将获得以下内容 ghc-options
- -threaded
- -rtsopts
- -with-rtsopts=-N
Run Code Online (Sandbox Code Playgroud)
看着man ghc,我发现了以下内容:
-threaded
Use the threaded runtime
-rtsopts[=?none|some|all?]
Control whether the RTS behaviour can be tweaked via command-lineflags and the GHCRTS environment variable. Using none means no RTS
flags can be given; some means only a minimum of safe options can be given (the default), and all (or no argument at all) means
that all RTS flags are permitted.
-with-rtsopts=?opts?
Set the default RTS options to ?opts?.
Run Code Online (Sandbox Code Playgroud)
这几乎没有告诉我什么.线程运行时是指引用编译器的运行时还是生成的可执行文件的运行时?这些rtsopts是什么?这些选择在某种程度上有益吗?如果是,为什么它们不是默认值?为什么可执行文件得到它们而库代码却没有:
library:
source-dirs: …Run Code Online (Sandbox Code Playgroud) stack build我正在从 Haskell 应用程序构建 docker 映像,并在容器内执行。
因为stack build是从“新鲜/普通”docker 映像开始 - 所有库都需要安装/拉取。
有没有办法可以预安装这些库依赖项?为了减少 docker 镜像构建时间的最终目标 ( stack build)。我还希望能够稍后“添加”额外的依赖项,而不必再次stack build从头开始。
一个可能的解决方案:
我尝试了一系列:
RUN stack install --only-dependencies --resolver="lts-14.27" aeson
RUN stack install --only-dependencies --resolver="lts-14.27" aeson-pretty
RUN stack install --only-dependencies --resolver="lts-14.27" ansi-terminal
RUN stack install --only-dependencies --resolver="lts-14.27" ansi-wl-pprint
RUN stack install --only-dependencies --resolver="lts-14.27" appar
RUN stack install --only-dependencies --resolver="lts-14.27" array
RUN stack install --only-dependencies --resolver="lts-14.27" asn1-encoding
RUN stack install --only-dependencies --resolver="lts-14.27" asn1-parse
RUN stack install --only-dependencies --resolver="lts-14.27" asn1-types …Run Code Online (Sandbox Code Playgroud)