Installing Haskell packages on Mac

2019-03-09 17:33发布

I can't seem to get a few Haskell packages to install on my Mac (10.6.8). I first tried Happstack and it failed and then I tried Snap.

Sometimes when I run ghci I get a segmentation fault.

Other times it works and goes like this:

GHCi, version 7.4.2: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude>

When trying to get Snap:

....
....
....
Loading package vector-0.10.0.1 ... linking ... done.
Loading package zlib-0.5.4.0 ... linking ... done.
Loading package zlib-bindings-0.1.1.3 ... linking ... done.
Loading package zlib-enum-0.2.3 ... linking ... done.
Loading package snap-core-0.9.3.1 ... linking ... done.
Loading package snap-server-0.9.3.3 ... linking ... done.
Loading package directory-tree-0.11.0 ... linking ... done.
cabal: Error: some packages failed to install:
snap-0.11.2 failed during the building phase. The exception was:
ExitFailure 11

I have seen this problem a few times but nothing really solved it for me. Any ideas?

7条回答
男人必须洒脱
2楼-- · 2019-03-09 17:56

Update: February 2016: Whilst other answers were helpful, I didn't find a complete, up-to-date answer.

The install is easy:

$ brew install ghc cabal-install

An extra step I needed to perform post-install was:

$ cabal update

followed by:

$ cabal install ghc-mod

See here for details.

haskell install

Alternatively, instead of using homebrew for the install, visit Haskell Platform for the installer disk image - note that Haskell Platform is only compatible with OS X 10.6 and later.

Although, as a general rule I always use homebrew to manage my dependencies, when it comes to Haskell my recommendation (unless you really know what you are doing) is to just install this binary. This avoids any surprises further down the road. There is excellent documentation post install locally at: file:///Library/Haskell/doc/start.html

The popular answer to this question (using brew to install haskell-platform) is no longer supported.

not supported

查看更多
爷的心禁止访问
3楼-- · 2019-03-09 18:03

Late 2017 answer. I'm running macOS Sierra -- 10.12.6 (16G29). This worked successfully with an install time on my MacBook Air of under five minutes:

brew cask install haskell-platform

Then ghc --version reported:

The Glorious Glasgow Haskell Compilation System, version 8.2.1

查看更多
Luminary・发光体
4楼-- · 2019-03-09 18:04

This is an old question but given it comes quiet high on Google search. This is how I got here.

$ brew update
$ brew install haskell-stack
$ stack --version
$ stack --help # "man stack" gives something completely different
$ stack setup # Install GHC
$ stack ghci

Source: http://seanhess.github.io/2015/08/04/practical-haskell-getting-started.html

Why stack and not cabal?

Edit:

I found annoying to have to write "stack ghci" each time I wanted to use "ghci". A solution to this was to simply add these lines to the ~/.bash_aliases file:

alias sghc='stack ghc'
alias sghci='stack ghci'
alias srunhaskell='stack runhaskell'

Then source the file to apply:

$ source ~/.bash_aliases

Then I can run ghci and / or haskell running these commands, and it will use the stack version:

$ sghc [filename]
$ sghci
$ srunhaskell
查看更多
Juvenile、少年°
5楼-- · 2019-03-09 18:05

brew install haskell-platform is no longer supported. You may want to

Error: No available formula for haskell-platform
We no longer package haskell-platform. Consider installing ghc and cabal-install instead:
brew install ghc cabal-install

查看更多
三岁会撩人
6楼-- · 2019-03-09 18:10

Have you tried using homebrew? It handles the dependencies for you. I am on Mac OS X 10.7.5, but these instructions should work for you.

Using homebrew, you can install haskell-platform using the brew command. It will take a while. The compile stage for haskell-platform took 15 minutes.

$ brew search haskell
haskell-platform

$ brew install haskell-platform
==> Installing haskell-platform dependency: ghc
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/ghc-7.4.2.lion.bottle.1.tar.gz
######################################################################## 100.0%
==> Pouring ghc-7.4.2.lion.bottle.1.tar.gz
==> Caveats
This brew is for GHC only; you might also be interested in haskell-platform.
==> Summary
                                                                    
查看更多
神经病院院长
7楼-- · 2019-03-09 18:17

Since haskell-platform on homebrew for Mac is deprecated, you can use brew install ghc cabal-install instead. I did it on Yosemite and it took about one minute…

> $ brew install ghc cabal-install                                             
==> Downloading https://homebrew.bintray.com/bottles/ghc-7.10.1_1.yosemite.bottl
######################################################################## 100.0%
==> Pouring ghc-7.10.1_1.yosemite.bottle.tar.gz
                                                                    
查看更多
登录 后发表回答