这肯定很简单,但是为什么这个错误:
PS C:\Users\guthrie\Desktop> cabal install --lib timeit
Resolving dependencies...
Up to date
PS C:\Users\guthrie\Desktop> ghci
GHCi, version 8.10.2: https://www.haskell.org/ghc/ :? for help
Prelude> :m System.TimeIt
<no location info>: error:
Could not find module `System.TimeIt'
Perhaps you meant System.Timeout (from base-4.14.1.0)
Prelude>
Leaving GHCi.Hackage显示System.TimeIt是在timeit-2.0中定义的,这是阴谋集团所安装的。
PS C:\Users\guthrie\Desktop> cabal install timeit
Resolving dependencies...
Build profile: -w ghc-8.10.2 -O1
In order, the following will be built (use -v for more details):
- timeit-2.0 (lib) (requires download & build)
Downloading timeit-2.0
Downloaded timeit-2.0
Starting timeit-2.0 (lib)
Building timeit-2.0 (lib)
Installing timeit-2.0 (lib)
Completed timeit-2.0 (lib)再次检查:
PS C:\Users\guthrie\Desktop> cabal install --lib timeit
Resolving dependencies...
Up to date但是试图从阴谋集团的信息中查出来:
PS C:\Users\guthrie\Desktop> cabal info timeit
* timeit (library)
Synopsis: Time monadic computations with an IO base.
Versions available: 0.9.0.0, 1.0.0.0, 2.0
Versions installed: [ Not installed ]
Homepage: https://github.com/merijn/timeit
Bug reports: https://github.com/merijn/timeit/issues
Description: A simple wrapper to show the used CPU time of monadic
computation with an IO base.
Category: System
License: BSD3
Author: Lennart Augustsson
Maintainer: Merijn Verstraaten <merijn@inconsistent.nl>, Lennart Augustsson
Source repo: ssh://github.com:merijn/timeit.git
Dependencies: base >=3 && <5, transformers >=0.2 && <0.6
Cached: Yes
Modules:
System.TimeIt所以它报告说:“没有安装”。准则(Criterion.Main)也有同样的问题。
我看到了2/2020的注释,如果没有-lib选项就安装了一个软件包,
--在本例中,它确实将库添加到包db,但没有将其添加到默认环境中。(*https://github.com/haskell/cabal/issues/6262#issuecomment-589843722)
因此,我重复了这个选项的安装,没有效果-只是报告了“最新”。
同样的链接给出了解决方案(解决方案?)改为使用阴谋v1-安装,这是可行的。但是,建议的简单解决方案是怎样才能只使用ghci来测试小代码呢?强制迁移到堆栈,本地沙箱和每一个小测试的所有副本?
由于我只是对示例进行非常简单的简短测试,所以我没有为每个示例创建一个沙箱,也没有一个.cabal文件,这些文件现在需要吗?!
(阴谋3.2.0.o,ghc 8.10.2,Windows 10)
发布于 2021-03-21 08:23:51
我强烈建议您不要尝试直接使用ghc和ghci,而是使用cabal。如果您想在REPL中快速地使用timeit,那么请使用
cabal v2-repl --build-depends timeit如果您想做任何更复杂的事情,那么创建一个(可能是临时的)项目并将timeit添加为依赖项:
$ mkdir my-temporary-package
$ cd my-temporary-package
$ cabal init编辑my-temporary-package.cabal以更改
build-depends: base >=... && <...至
build-depends: base, timeit(基础上的约束会给你带来更多的伤害,而不是对一个快速探索项目的好处。)如果有必要,可以稍后将它们添加回。)然后
$ cabal v2-repl将为您提供一个timeit可用的REPL。
https://stackoverflow.com/questions/65836038
复制相似问题