昨天我尝试通过 cabal 安装 Haskell 模块,以便熟悉 Haskell 中模块的安装。我必须先安装 cabal。
我的系统:Windows 7
Haskell 编译器版本:GHC 7.0.2(链接 http://www.haskell.org/ghc/download)
cabal :http://haskell.org/cabal/download.html
我会一步一步描述这个过程,希望你能指出我在cabal和用cabal安装包时的错误行为。
过程:
已安装 Haskell 编译器 GHC 7.0.2
从 Windows 7 开始菜单启动 GHCi,在 DOS 窗口中提供以下输出:
GHCi, version 7.0.2: Website :? for help .
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package ffi-1.0 ... linking ... done.
Prelude>
到目前为止一切顺利:基础包中的每个函数都可以访问,并且按照预期的方式运行。
结论:GHCi安装没有错误步骤。
从源代码下载 cabal.exe(见介绍),将其复制到 C:\ghc\ghc-7.0.2\bin(添加到 %Path%-variables 中)
cabal-install-0.8.2.tar.gz,因为该站点建议用户需要该软件包才能进行全新安装。cabal update(根据站点建议),它确实更新了列表并返回到用户提示模式cd C:\pathwhere\cabal-install-0.8.2.tar.gz(切换到cabal-install文件所在目录)键入 cabal install cabal-install-0.8.2,此后安装开始在 dos 框中创建以下输出:
Resolving dependencies...
Downloading containers-0.3.0.0...
Configuring containers-0.3.0.0...
Preprocessing library containers-0.3.0.0...
Building containers-0.3.0.0...
[1 of 7] Compiling Data.Sequence ( Data\Sequence.hs, dist\build\Data\Sequence.o )
[2 of 7] Compiling Data.Set ( Data\Set.hs, dist\build\Data\Set.o )
[3 of 7] Compiling Data.Map ( Data\Map.hs, dist\build\Data\Map.o )
[4 of 7] Compiling Data.IntSet ( Data\IntSet.hs, dist\build\Data\IntSet.o )
[5 of 7] Compiling Data.IntMap ( Data\IntMap.hs, dist\build\Data\IntMap.o )
[6 of 7] Compiling Data.Tree ( Data\Tree.hs, dist\build\Data\Tree.o )
[7 of 7] Compiling Data.Graph ( Data\Graph.hs, dist\build\Data\Graph.o )
cabal: ar is required but it could not be found.
Downloading filepath-1.1.0.4...
Configuring filepath-1.1.0.4...
Preprocessing library filepath-1.1.0.4...
Building filepath-1.1.0.4...
[1 of 3] Compiling System.FilePath.Posix ( System\FilePath\Posix.hs, dist\build\System\FilePath\Posix.o )
[2 of 3] Compiling System.FilePath.Windows ( System\FilePath\Windows.hs, dist\build\System\FilePath\Windows.o )
[3 of 3] Compiling System.FilePath ( System\FilePath.hs, dist\build\System\FilePath.o )
cabal: ar is required but it could not be found.
Downloading parsec-2.1.0.1...
Configuring parsec-2.1.0.1...
Preprocessing library parsec-2.1.0.1...
Building parsec-2.1.0.1...
[ 1 of 10] Compiling Text.ParserCombinators.Parsec.Pos ( Text\ParserCombinators\Parsec\Pos.hs, dist\build\Text\ParserCombinators\Parsec\Pos.o )
[ 2 of 10] Compiling Text.ParserCombinators.Parsec.Error ( Text\ParserCombinators\Parsec\Error.hs, dist\build\Text\ParserCombinators\Parsec\Error.o )
[ 3 of 10] Compiling Text.ParserCombinators.Parsec.Prim ( Text\ParserCombinators\Parsec\Prim.hs, dist\build\Text\ParserCombinators\Parsec\Prim.o )
[ 4 of 10] Compiling Text.ParserCombinators.Parsec.Char ( Text\ParserCombinators\Parsec\Char.hs, dist\build\Text\ParserCombinators\Parsec\Char.o )
[ 5 of 10] Compiling Text.ParserCombinators.Parsec.Combinator ( Text\ParserCombinators\Parsec\Combinator.hs, dist\build\Text\ParserCombinators\Parsec\Combinator.o )
[ 6 of 10] Compiling Text.ParserCombinators.Parsec.Expr ( Text\ParserCombinators\Parsec\Expr.hs, dist\build\Text\ParserCombinators\Parsec\Expr.o )
[ 7 of 10] Compiling Text.ParserCombinators.Parsec ( Text\ParserCombinators\Parsec.hs, dist\build\Text\ParserCombinators\Parsec.o )
[ 8 of 10] Compiling Text.ParserCombinators.Parsec.Token ( Text\ParserCombinators\Parsec\Token.hs, dist\build\Text\ParserCombinators\Parsec\Token.o )
[ 9 of 10] Compiling Text.ParserCombinators.Parsec.Perm ( Text\ParserCombinators\Parsec\Perm.hs, dist\build\Text\ParserCombinators\Parsec\Perm.o )
[10 of 10] Compiling Text.ParserCombinators.Parsec.Language ( Text\ParserCombinators\Parsec\Language.hs, dist\build\Text\ParserCombinators\Parsec\Language.o )
cabal: ar is required but it could not be found.
Downloading time-1.1.4...
[1 of 1] Compiling Main ( C:\Users\altug\AppData\Local\Temp\time-1.1.43528time-1.1.4\Setup.hs, C:\Users\altug\AppData\Local\Temp\time-1.1.43528\time-1.1.4\dist\setup\Main.o )
C:\Users\altug\AppData\Local\Temp\time-1.1.43528\time-1.1.4\Setup.hs:5:1:
Warning: In the use of `runTests'
(imported from Distribution.Simple, but defined in Distribution.Simple.UserHooks):
Deprecated: "Please use the new testing interface instead!"
Linking C:\Users\altug\AppData\Local\Temp\time-1.1.43528\time-1.1.4\dist\setup\setup.exe ...
Configuring time-1.1.4...
Preprocessing library time-1.1.4...
Building time-1.1.4...
[ 1 of 24] Compiling Data.Time.Clock.CTimeval ( Data\Time\Clock\CTimeval.hs, dist\build\Data\Time\Clock\CTimeval.o )
[ 2 of 24] Compiling Data.Time.Clock.Scale ( Data\Time\Clock\Scale.hs, dist\build\Data\Time\Clock\Scale.o )
[ 3 of 24] Compiling Data.Time.Calendar.Private ( Data\Time\Calendar\Private.hs, dist\build\Data\Time\Calendar\Private.o )
[ 4 of 24] Compiling Data.Time.Calendar.MonthDay ( Data\Time\Calendar\MonthDay.hs, dist\build\Data\Time\Calendar\MonthDay.o )
[ 5 of 24] Compiling Data.Time.Calendar.Days ( Data\Time\Calendar\Days.hs, dist\build\Data\Time\Calendar\Days.o )
[ 6 of 24] Compiling Data.Time.Calendar.OrdinalDate ( Data\Time\Calendar\OrdinalDate.hs, dist\build\Data\Time\Calendar\OrdinalDate.o )
[ 7 of 24] Compiling Data.Time.Calendar.Gregorian ( Data\Time\Calendar\Gregorian.hs, dist\build\Data\Time\Calendar\Gregorian.o )
[ 8 of 24] Compiling Data.Time.Calendar.WeekDate ( Data\Time\Calendar\WeekDate.hs, dist\build\Data\Time\Calendar\WeekDate.o )
[ 9 of 24] Compiling Data.Time.Calendar.JulianYearDay ( Data\Time\Calendar\JulianYearDay.hs, dist\build\Data\Time\Calendar\JulianYearDay.o )
[10 of 24] Compiling Data.Time.Calendar.Julian ( Data\Time\Calendar\Julian.hs, dist\build\Data\Time\Calendar\Julian.o )
[11 of 24] Compiling Data.Time.Clock.UTC ( Data\Time\Clock\UTC.hs, dist\build\Data\Time\Clock\UTC.o )
[12 of 24] Compiling Data.Time.Clock.POSIX ( Data\Time\Clock\POSIX.hs, dist\build\Data\Time\Clock\POSIX.o )
[13 of 24] Compiling Data.Time.Clock.UTCDiff ( Data\Time\Clock\UTCDiff.hs, dist\build\Data\Time\Clock\UTCDiff.o )
[14 of 24] Compiling Data.Time.Clock ( Data\Time\Clock.hs, dist\build\Data\Time\Clock.o )
[15 of 24] Compiling Data.Time.LocalTime.TimeZone ( Data\Time\LocalTime\TimeZone.hs, dist\build\Data\Time\LocalTime\TimeZone.o )
[16 of 24] Compiling Data.Time.LocalTime.TimeOfDay ( Data\Time\LocalTime\TimeOfDay.hs, dist\build\Data\Time\LocalTime\TimeOfDay.o )
[17 of 24] Compiling Data.Time.Calendar ( Data\Time\Calendar.hs, dist\build\Data\Time\Calendar.o )
[18 of 24] Compiling Data.Time.Calendar.Easter ( Data\Time\Calendar\Easter.hs, dist\build\Data\Time\Calendar\Easter.o )
[19 of 24] Compiling Data.Time.LocalTime.LocalTime ( Data\Time\LocalTime\LocalTime.hs, dist\build\Data\Time\LocalTime\LocalTime.o )
[20 of 24] Compiling Data.Time.LocalTime ( Data\Time\LocalTime.hs, dist\build\Data\Time\LocalTime.o )
[21 of 24] Compiling Data.Time.Clock.TAI ( Data\Time\Clock\TAI.hs, dist\build\Data\Time\Clock\TAI.o )
[22 of 24] Compiling Data.Time.Format.Parse ( Data\Time\Format\Parse.hs, dist\build\Data\Time\Format\Parse.o )
[23 of 24] Compiling Data.Time.Format ( Data\Time\Format.hs, dist\build\Data\Time\Format.o )
[24 of 24] Compiling Data.Time ( Data\Time.hs, dist\build\Data\Time.o )
Registering time-1.1.4...
Installing library in
C:\Users\altug\AppData\Roaming\cabal\time-1.1.4\ghc-7.0.2
Registering time-1.1.4...
Downloading random-1.0.0.3...
Configuring random-1.0.0.3...
Preprocessing library random-1.0.0.3...
Building random-1.0.0.3...
[1 of 1] Compiling System.Random ( System\Random.hs, dist\build\System\Random.o )
cabal: ar is required but it could not be found.
Downloading transformers-0.2.2.0...
Configuring transformers-0.2.2.0...
Preprocessing library transformers-0.2.2.0...
Building transformers-0.2.2.0...
[ 1 of 21] Compiling Data.Functor.Product ( Data\Functor\Product.hs, dist\buildData\Functor\Product.o )
[ 2 of 21] Compiling Data.Functor.Constant ( Data\Functor\Constant.hs, dist\build\Data\Functor\Constant.o )
[ 3 of 21] Compiling Data.Functor.Compose ( Data\Functor\Compose.hs, dist\build\Data\Functor\Compose.o )
[ 4 of 21] Compiling Data.Functor.Identity ( Data\Functor\Identity.hs, dist\build\Data\Functor\Identity.o )
[ 5 of 21] Compiling Control.Monad.Trans.Class ( Control\Monad\Trans\Class.hs, dist\build\Control\Monad\Trans\Class.o )
[ 6 of 21] Compiling Control.Monad.IO.Class ( Control\Monad\IO\Class.hs, dist\build\Control\Monad\IO\Class.o )
[ 7 of 21] Compiling Control.Monad.Trans.Cont ( Control\Monad\Trans\Cont.hs, dist\build\Control\Monad\Trans\Cont.o )
[ 8 of 21] Compiling Control.Monad.Trans.Error ( Control\Monad\Trans\Error.hs, dist\build\Control\Monad\Trans\Error.o )
[ 9 of 21] Compiling Control.Monad.Trans.Identity ( Control\Monad\Trans\Identity.hs, dist\build\Control\Monad\Trans\Identity.o )
[10 of 21] Compiling Control.Monad.Trans.List ( Control\Monad\Trans\List.hs, dist\build\Control\Monad\Trans\List.o )
[11 of 21] Compiling Control.Monad.Trans.Maybe ( Control\Monad\Trans\Maybe.hs, dist\build\Control\Monad\Trans\Maybe.o )
[12 of 21] Compiling Control.Monad.Trans.Reader ( Control\Monad\Trans\Reader.hs, dist\build\Control\Monad\Trans\Reader.o )
[13 of 21] Compiling Control.Monad.Trans.RWS.Lazy ( Control\Monad\Trans\RWS\Lazy.hs, dist\build\Control\Monad\Trans\RWS\Lazy.o )
[14 of 21] Compiling Control.Monad.Trans.RWS ( Control\Monad\Trans\RWS.hs, dist\build\Control\Monad\Trans\RWS.o )
[15 of 21] Compiling Control.Monad.Trans.RWS.Strict ( Control\Monad\Trans\RWS\Strict.hs, dist\build\Control\Monad\Trans\RWS\Strict.o )
[16 of 21] Compiling Control.Monad.Trans.State.Lazy ( Control\Monad\Trans\State\Lazy.hs, dist\build\Control\Monad\Trans\State\Lazy.o )
[17 of 21] Compiling Control.Monad.Trans.State ( Control\Monad\Trans\State.hs, dist\build\Control\Monad\Trans\State.o )
[18 of 21] Compiling Control.Monad.Trans.State.Strict ( Control\Monad\Trans\State\Strict.hs, dist\build\Control\Monad\Trans\State\Strict.o )
[19 of 21] Compiling Control.Monad.Trans.Writer.Lazy ( Control\Monad\Trans\Writer\Lazy.hs, dist\build\Control\Monad\Trans\Writer\Lazy.o )
[20 of 21] Compiling Control.Monad.Trans.Writer ( Control\Monad\Trans\Writer.hs, dist\build\Control\Monad\Trans\Writer.o )
[21 of 21] Compiling Control.Monad.Trans.Writer.Strict ( Control\Monad\Trans\Writer\Strict.hs, dist\build\Control\Monad\Trans\Writer\Strict.o )
cabal: ar is required but it could not be found.
Downloading zlib-0.5.3.1...
Configuring zlib-0.5.3.1...
Preprocessing library zlib-0.5.3.1...
Building zlib-0.5.3.1...
[1 of 5] Compiling Codec.Compression.Zlib.Stream ( dist\build\Codec\Compression\Zlib\Stream.hs, dist\build\Codec\Compression\Zlib\Stream.o )
[2 of 5] Compiling Codec.Compression.Zlib.Internal ( Codec\Compression\Zlib\Internal.hs, dist\build\Codec\Compression\Zlib\Internal.o )
[3 of 5] Compiling Codec.Compression.Zlib.Raw ( Codec\Compression\Zlib\Raw.hs, dist\build\Codec\Compression\Zlib\Raw.o )
[4 of 5] Compiling Codec.Compression.Zlib ( Codec\Compression\Zlib.hs, dist\build\Codec\Compression\Zlib.o )
[5 of 5] Compiling Codec.Compression.GZip ( Codec\Compression\GZip.hs, dist\build\Codec\Compression\GZip.o )
cabal: ar is required but it could not be found.
cabal: Error: some packages failed to install:
Cabal-1.8.0.6 depends on filepath-1.1.0.4 which failed to install.
HTTP-4000.1.1 depends on transformers-0.2.2.0 which failed to install.
cabal-install-0.8.2 depends on zlib-0.5.3.1 which failed to install.
containers-0.3.0.0 failed during the building phase. The exception was:
ExitFailure 1
directory-1.0.1.2 depends on filepath-1.1.0.4 which failed to install.
filepath-1.1.0.4 failed during the building phase. The exception was:
ExitFailure 1
mtl-2.0.1.0 depends on transformers-0.2.2.0 which failed to install.
network-2.3.0.2 depends on parsec-2.1.0.1 which failed to install.
parsec-2.1.0.1 failed during the building phase. The exception was:
ExitFailure 1
process-1.0.1.5 depends on filepath-1.1.0.4 which failed to install.
random-1.0.0.3 failed during the building phase. The exception was:
ExitFailure 1
transformers-0.2.2.0 failed during the building phase. The exception was:
ExitFailure 1
zlib-0.5.3.1 failed during the building phase. The exception was:
ExitFailure 1
我的结论:
很容易看出,输出显示了一些错误,但我不知道它们是什么意思。我继续尝试安装我的代数包,重点是使它从第 1 步开始对 Dos-Interpeter 可用。
再次在 dos-box 输入提示符下,我输入了 cabal install constructive-algebra,这产生了这个输出:
Resolving dependencies...
cabal: cannot configure algebra-0.0.0.1. It requires base >=3.0 && <4.1
For the dependency on base >=3.0 && <4.1 there are these packages:
base-3.0.3.1, base-3.0.3.2 and base-4.0.0.0. However none of them are available.
base-3.0.3.1 was excluded because of the top level dependency base -any
base-3.0.3.2 was excluded because of the top level dependency base -any
base-4.0.0.0 was excluded because of the top level dependency base -any
我想这个包没有安装。我需要有人可以解释我需要执行哪些具体步骤才能使模块正常工作。
感谢您阅读这篇文章并以让我理解它的方式回答以及解释器和编译器的工作。
最佳答案
最简单的方法是像 DasBoot 推荐的那样获得 Haskell 平台,但无论如何我都会尝试回答您的问题:
1) 对于问题的第一部分,您的安装失败是因为您的路径有问题。找不到工具“ar”。 ar 在创建库时使用。如果您在命令窗口中只键入“ar”,它应该返回类似于
Usage: ar [emulation options] [-]{dmpqrstx}[abcfilNoPsSuvV] [member-name] [count ] archive-file file... ar -M [
如果没有,则需要将包含 ar 的文件夹(可能是 C:\ghc\ghc-7.0.2\mingw\bin)添加到 Windows 中的路径环境变量中。
2) 你的代数库不会安装在 7.0.2 下,至少不是开箱即用的。代数有一个依赖项,列为“依赖项:base >=3.0 && <>
但是 ghc 7.0 带有 base 4.3。这就是您收到的原因:
cabal: cannot configure algebra-0.0.0.1. It requires base >=3.0 && <4.1
For the dependency on base >=3.0 && <4.1 there are these packages:
base-3.0.3.1, base-3.0.3.2 and base-4.0.0.0. However none of them are available
幸运的是,对于这个特定的空气包,这个问题可以很容易地解决。就这样
cabal unpack algebra
cd algebra-0.0.0.1
notepad algebra.cabal
change the 4.1 to a 4.4
cabal install
这样就可以了
关于windows - 在 Windows 7 上安装 Haskell 模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5218419/
假设我做了一个模块如下:m=Module.newdoclassCendend三个问题:除了对m的引用之外,还有什么方法可以访问C和m中的其他内容?我可以在创建匿名模块后为其命名吗(就像我输入“module...”一样)?如何在使用完匿名模块后将其删除,使其定义的常量不再存在? 最佳答案 三个答案:是的,使用ObjectSpace.此代码使c引用你的类(class)C不引用m:c=nilObjectSpace.each_object{|obj|c=objif(Class===objandobj.name=~/::C$/)}当然这取决于
作为我的Rails应用程序的一部分,我编写了一个小导入程序,它从我们的LDAP系统中吸取数据并将其塞入一个用户表中。不幸的是,与LDAP相关的代码在遍历我们的32K用户时泄漏了大量内存,我一直无法弄清楚如何解决这个问题。这个问题似乎在某种程度上与LDAP库有关,因为当我删除对LDAP内容的调用时,内存使用情况会很好地稳定下来。此外,不断增加的对象是Net::BER::BerIdentifiedString和Net::BER::BerIdentifiedArray,它们都是LDAP库的一部分。当我运行导入时,内存使用量最终达到超过1GB的峰值。如果问题存在,我需要找到一些方法来更正我的代
我需要在客户计算机上运行Ruby应用程序。通常需要几天才能完成(复制大备份文件)。问题是如果启用sleep,它会中断应用程序。否则,计算机将持续运行数周,直到我下次访问为止。有什么方法可以防止执行期间休眠并让Windows在执行后休眠吗?欢迎任何疯狂的想法;-) 最佳答案 Here建议使用SetThreadExecutionStateWinAPI函数,使应用程序能够通知系统它正在使用中,从而防止系统在应用程序运行时进入休眠状态或关闭显示。像这样的东西:require'Win32API'ES_AWAYMODE_REQUIRED=0x0
我想为Heroku构建一个Rails3应用程序。他们使用Postgres作为他们的数据库,所以我通过MacPorts安装了postgres9.0。现在我需要一个postgresgem并且共识是出于性能原因你想要pggem。但是我对我得到的错误感到非常困惑当我尝试在rvm下通过geminstall安装pg时。我已经非常明确地指定了所有postgres目录的位置可以找到但仍然无法完成安装:$envARCHFLAGS='-archx86_64'geminstallpg--\--with-pg-config=/opt/local/var/db/postgresql90/defaultdb/po
我打算为ruby脚本创建一个安装程序,但我希望能够确保机器安装了RVM。有没有一种方法可以完全离线安装RVM并且不引人注目(通过不引人注目,就像创建一个可以做所有事情的脚本而不是要求用户向他们的bash_profile或bashrc添加一些东西)我不是要脚本本身,只是一个关于如何走这条路的快速指针(如果可能的话)。我们还研究了这个很有帮助的问题:RVM-isthereawayforsimpleofflineinstall?但有点误导,因为答案只向我们展示了如何离线在RVM中安装ruby。我们需要能够离线安装RVM本身,并查看脚本https://raw.github.com/wayn
我有一个包含模块的模型。我想在模块中覆盖模型的访问器方法。例如:classBlah这显然行不通。有什么想法可以实现吗? 最佳答案 您的代码看起来是正确的。我们正在毫无困难地使用这个确切的模式。如果我没记错的话,Rails使用#method_missing作为属性setter,因此您的模块将优先,阻止ActiveRecord的setter。如果您正在使用ActiveSupport::Concern(参见thisblogpost),那么您的实例方法需要进入一个特殊的模块:classBlah
我有一个奇怪的问题:我在rvm上安装了rubyonrails。一切正常,我可以创建项目。但是在我输入“railsnew”时重新启动后,我有“程序'rails'当前未安装。”。SystemUbuntu12.04ruby-v"1.9.3p194"gemlistactionmailer(3.2.5)actionpack(3.2.5)activemodel(3.2.5)activerecord(3.2.5)activeresource(3.2.5)activesupport(3.2.5)arel(3.0.2)builder(3.0.0)bundler(1.1.4)coffee-rails(
我刚刚为fedora安装了emacs。我想用emacs编写ruby。为ruby提供代码提示、代码完成类型功能所需的工具、扩展是什么? 最佳答案 ruby-mode已经包含在Emacs23之后的版本中。不过,它也可以通过ELPA获得。您可能感兴趣的其他一些事情是集成RVM、feature-mode(Cucumber)、rspec-mode、ruby-electric、inf-ruby、rinari(用于Rails)等。这是我当前用于Ruby开发的Emacs配置:https://github.com/citizen428/emacs
我正在尝试在我的centos服务器上安装therubyracer,但遇到了麻烦。$geminstalltherubyracerBuildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingtherubyracer:ERROR:Failedtobuildgemnativeextension./usr/local/rvm/rubies/ruby-1.9.3-p125/bin/rubyextconf.rbcheckingformain()in-lpthread...yescheckingforv8.h...no***e
我的最终目标是安装当前版本的RubyonRails。我在OSXMountainLion上运行。到目前为止,这是我的过程:已安装的RVM$\curl-Lhttps://get.rvm.io|bash-sstable检查已知(我假设已批准)安装$rvmlistknown我看到当前的稳定版本可用[ruby-]2.0.0[-p247]输入命令安装$rvminstall2.0.0-p247注意:我也试过这些安装命令$rvminstallruby-2.0.0-p247$rvminstallruby=2.0.0-p247我很快就无处可去了。结果:$rvminstall2.0.0-p247Search