在Ubuntu 14.04上安装Haskell以进行Web开发

时间:2014-07-19 02:21:38

标签: linux ubuntu haskell

如何在Ubuntu 14.04上使用Haskell进行Web开发?

我已阅读了大量教程,但没有任何工作。我在教程中途走了一半,终端中的某些东西惨遭失败,导致我不得不花费数小时寻找解决方案,只是为了回到我离开的地方。

我是否可以使用一些二进制文件在Linux上安装所有内容?我在软件中心找不到它。

3 个答案:

答案 0 :(得分:5)

使用Haskell Platform

sudo apt-get install haskell-platform

对于网站开发,我使用Yesod quick start中描述的方法,只有我在cabal sandbox

中执行此操作
cabal update
cabal sandbox init
cabal install happy alex yesod-platform yesod-bin --max-backjumps=-1 --reorder-goals
export PATH=.cabal-sandbox/bin/:$PATH
yesod devel

答案 1 :(得分:2)

另一种方法是通过Nix Package Manager安装yesod。

安装nix(http://nixos.org/nix/download.html):

bash <(curl https://nixos.org/nix/install)

安装yesod和一些工具:

nix-env -iA nixpkgs.haskellPackages.{hjsmin,persistentSqlite,yesod,yesodBin,yesodStatic,cabalInstall,ghc}

创建骨架项目:

yesod init

然后开始:

ghost@ubuntu:~/foo$ yesod devel
Yesod devel server. Press ENTER to quit
Warning: The package list for 'hackage.haskell.org' does not exist. Run 'cabal
update' to download it.
Resolving dependencies...
Configuring foo-0.0.0...
Forcing recompile for ./Model.hs because of config/models
Forcing recompile for ./Foundation.hs because of config/routes
Forcing recompile for ./Foundation.hs because of messages/en.msg
Forcing recompile for ./Foundation.hs because of templates/default-layout-wrapper.hamlet
Forcing recompile for ./Foundation.hs because of templates/default-layout.hamlet
Forcing recompile for ./Handler/Home.hs because of templates/homepage.hamlet
Forcing recompile for ./Handler/Home.hs because of templates/homepage.julius
Forcing recompile for ./Handler/Home.hs because of templates/homepage.lucius
Rebuilding application... (using cabal)
Starting development server...
Starting devel application
Devel application launched: http://localhost:3000
Migrating: CREATE TABLE "user"("id" INTEGER PRIMARY KEY,"ident" VARCHAR NOT NULL,"password" VARCHAR NULL,CONSTRAINT "unique_user" UNIQUE ("ident"))
Migrating: CREATE TABLE "email"("id" INTEGER PRIMARY KEY,"email" VARCHAR NOT NULL,"user" INTEGER NULL REFERENCES "user","verkey" VARCHAR NULL,CONSTRAINT "unique_email" UNIQUE ("email"))
20/Jul/2014:13:19:30 +0300 [Debug#SQL] "CREATE TABLE \"user\"(\"id\" INTEGER PRIMARY KEY,\"ident\" VARCHAR NOT NULL,\"password\" VARCHAR NULL,CONSTRAINT \"unique_user\" UNIQUE (\"ident\"))" [] @(persistent-1.3.1.1:Database.Persist.Sql.Raw ./Database/Persist/Sql/Raw.hs:38:5)
20/Jul/2014:13:19:30 +0300 [Debug#SQL] "CREATE TABLE \"email\"(\"id\" INTEGER PRIMARY KEY,\"email\" VARCHAR NOT NULL,\"user\" INTEGER NULL REFERENCES \"user\",\"verkey\" VARCHAR NULL,CONSTRAINT \"unique_email\" UNIQUE (\"email\"))" [] @(persistent-1.3.1.1:Database.Persist.Sql.Raw ./Database/Persist/Sql/Raw.hs:38:5)

答案 2 :(得分:0)

你的问题是你有旧的Cabal(版本1.16。*),它包含在Ubuntu 14.04中。你应该升级Cabal。我可以为您看到以下选项:

1)将整个Ubuntu升级到14.10。您将获得Cabal版本1.20。*。

2)如果您尚未准备好进行完整的操作系统升级,请仅升级Cabal:

2.1)暂时将以下行添加到/etc/apt/sources.list

deb http://no.archive.ubuntu.com/ubuntu/ utopic universe

2.2)运行:

sudo apt-get update
sudo apt-get install cabal-install

2.3)删除步骤2.1中添加到/etc/apt/sources.list的行。

2.4)运行:

sudo apt-get update

2.5)检查您的cabal是否已升级:

cabal --version

你应该得到:

cabal-install version 1.20.0.3
using version 1.20.0.2 of the Cabal library