How to install Haskell on Mac OS

匿名 (未验证) 提交于 2019-12-03 02:16:02

问题:

I am trying to install Haskell on my Macbook two days and can not get the success.

What I have done:

$ brew install ghc 

Fine. Now I am trying to install

$ cabal install text 

and get next error messages:

Data/Text.hs:1074:4:      error: invalid preprocessing directive       #-}        ^ 

I have googled and found this.

So:

  • brew install gcc48

    $ /usr/local/bin/gcc-4.8 --version   gcc-4.8 (GCC) 4.8.2 Copyright (C) 2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions.  There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  $ cat /usr/local/lib/ghc-7.6.3/settings   [("GCC extra via C opts", " -fwrapv"),    ("C compiler command", "/usr/local/bin/gcc-4.8"),    ("C compiler flags", " -m64 -fno-stack-protector  -m64"),    ... 
  • brew install cabal-install

  • cabal install text

And I get the same messages.

How can I fix them ?

回答1:

Try using the Mac version of the Haskell Platform, I don't have a Mac to try it out but my hope is that cabal will work out-of-the-box in the Haskell Platform.



回答2:

brew install ghc cabal-install

If you prefer homebrew.

Note: (Edited to add) Homebrew may have an older (or newer) version of ghc than the Haskell Platform download for OSX, and there might be other differences. You can check the release notes here for the version included in Haskell Platform, as well as other information of interest. brew info ghc cabal-install will give you up to date information about Homebrew's versions.



回答3:

If you want to install the Haskell Platform binaries via homebrew:

brew install cask brew cask install haskell-platform  cabal install cabal-install 


回答4:

There is a new ghc-dot-app project that is an alternative to Homebrew formula and Haskell Platform official installer. Here is the project's web page: Haskell for Mac OS X. Here is a discussion thread about it on Haskell Cafe: "Self-contained GHC for Mac". Here is a quote from the author's posting:

How does it work?

In https://github.com/ghcformacosx/ghc-dot-app I have a Main.hs script which downloads/builds/etc. all of the prerequisites. Then it patches the shell scripts to use a path relative to themselves (after following symlinks) rather than hard-coding an installation location. It also patches the package.conf.d files to use ${pkgroot} relative paths.

Separately, there's an Xcode project that includes all of the metadata to make it look like a real Mac app bundle (icons, Info.plist) and a small Cocoa application that has a button to open the docs and provides instructions for adding it to the PATH in .bashrc. Due to the heuristics in Mac OS X's man, this will automatically make man pages work as well.



回答5:

The following information suggests there may be a mac installer available:

brew info haskell-platform  We no longer package haskell-platform. Consider installing ghc and cabal-install instead:  brew install ghc cabal-install  A binary installer is available: https://www.haskell.org/platform/mac.html 


回答6:

Try installing Haskell using brew install haskell-platform.

If you are already on Mavericks you will have to install GCC (as Mavericks ships with Clang). Follow the instructions here:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!