Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install Haskell on Mac OS

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 ?

like image 672
ceth Avatar asked Mar 19 '14 07:03

ceth


People also ask

How do I download and install Haskell?

Run the command "$ sudo apt-get install haskell-platform" and press Enter. It will automatically start downloading Haskell on your system after authenticating you with the root password. After installing, you will receive a confirmation message.

How do I run Haskell on Mac terminal?

If you have installed the Haskell Platform, open a terminal and type ghci (the name of the executable of the GHC interpreter) at the command prompt. Alternatively, if you are on Windows, you may choose WinGHCi in the Start menu. And you are presented with a prompt. The Haskell system now attentively awaits your input.


1 Answers

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.

Note: The last time I did this, I just installed haskell-stack instead, as described in Filippo's answer.

like image 168
derekv Avatar answered Oct 02 '22 13:10

derekv