Personal tools

Mac OS X

From HaskellWiki

(Difference between revisions)
Jump to: navigation, search
(remove standalone GHC installer, since with 6.12 this is not recommended anymore)
m (Changed Mac OS X path)
(25 intermediate revisions by 15 users not shown)
Line 1: Line 1:
  +
There is also now the [[Mac OS X Strike Force]] that aims to improve using Haskell on OS X.
  +
  +
== The Haskell Platform ==
  +
  +
There are Mac OS X installers of the full Haskell Platform development environment. We recommend it:
  +
  +
[http://haskell.org/platform/ http://haskell.org/platform/icons/button-100.png]
  +
 
== GHC ==
 
== GHC ==
  +
  +
==== Important notes ====
  +
  +
To get the most out of your GHC environment, you should add '~/Library/Haskell/bin' to your PATH environment variable before the path where you have GHC installed. This will allow you to get and use cabal-updates, as well as other programs shipped with GHC like hsc2hs.
  +
  +
In your ~/.profile, add the line:
  +
  +
<code>export PATH=$HOME/Library/Haskell/bin:$PATH</code>
   
 
=== Mac OS X 10.5 (Leopard) ===
 
=== Mac OS X 10.5 (Leopard) ===
Line 7: Line 23:
 
* install [http://www.macports.org MacPort]'s [http://trac.macports.org/browser/trunk/dports/lang/ghc/Portfile ghc] package
 
* install [http://www.macports.org MacPort]'s [http://trac.macports.org/browser/trunk/dports/lang/ghc/Portfile ghc] package
   
=== Mac OS X 10.6 (Snow Leopard) ===
+
=== Mac OS X 10.6 (Snow Leopard) and 10.7 (Lion) ===
Mac OS X 10.6.x (Snow Leopard) is currently not well supported.
 
The problem is that GHC generates 32bit code, but gcc on Snow Leopard defaults to 64bit code now.
 
   
The workaround is to tell gcc to accept 32bit code:
+
* Install the [http://hackage.haskell.org/platform/ Haskell Platform]
   
* install the [http://hackage.haskell.org/platform/ Haskell Platform]
+
To uninstall ghc call:
* patch the following wrapper scripts to include the flags "-optc-m32 -opta-m32 -optl-m32":
+
<code>
** /usr/bin/ghc
+
sudo uninstall-hs
** /usr/bin/ghci
+
</code>
** /usr/bin/runhaskell
 
** /usr/bin/runghc
 
** /usr/bin/hsc2hs
 
   
See also [http://passingcuriosity.com/2009/haskell-on-snow-leopard/ Haskell on Snow Leopard].
+
=== Xcode 4.1 ===
   
To uninstall call:
+
GHC needs Xcode to be installed so it has access to the bintools, headers, and link libraries of the platform. The later two are provided by the SDK that comes as part of Xcode. GHC 7.0.2 is compiled against the 10.5 SDK. Xcode 4.1 no longer ships with it. <tt>ghci</tt> will work, but linking and some compiles with <ghc> will not. To make those work you need a copy of the 10.5 SDK. You can get this one several ways:
   
<code>
+
* Before you install Xcode 4.1, if you have Xcode 3.2 installed, do one of the following:
sudo /Library/Frameworks/GHC.framework/Tools/Uninstaller
+
** Move it aside (renaming <tt>/Developer</tt> to <tt>/Xcode3.2</tt>)
</code>
+
** Move just the sdk aside (moving <tt>/Developer/SDKs/MacOSX10.5.sdk</tt> to, say, <tt>/ExtraSDKs/MacOSX10.5.sdk</tt>)
  +
** Move just the sdk aside, install Xcode 4.1, then move it back into the <tt>/Developer/SDKs</tt> directory.
  +
* If you don't have Xcode 3.2, then you can download it from the Apple Developer site, and install it in a location other than "/Developer". If you have already installed Xcode 4.1 ''be sure'' that you customized the install and don't install the "System Tools" or "UNIX Development" packages.
  +
  +
Building via GHC:
  +
ghc --make -I{loc}/MacOSX10.5.sdk/usr/include/ -L{loc}/MacOSX10.5.sdk/usr/lib
  +
  +
Building via cabal:
  +
cabal --extra-include-dirs={loc}/MacOSX10.5.sdk/usr/include/ --extra-lib-dirs={loc}/MacOSX10.5.sdk/usr/lib
  +
  +
Replace <tt>{loc}</tt> with wherever you put the SDK.
   
 
== HUGS ==
 
== HUGS ==
   
 
* install [http://www.macports.org MacPort]'s [http://trac.macports.org/browser/trunk/dports/lang/hugs98/Portfile hugs98] package.
 
* install [http://www.macports.org MacPort]'s [http://trac.macports.org/browser/trunk/dports/lang/hugs98/Portfile hugs98] package.
  +
  +
  +
== Installing libraries with external C bindings ==
  +
  +
Haskell libraries are installed with the <code>cabal</code> command line tool.
  +
  +
Some libraries depend on external C libraries, which are best installed with [http://macports.org MacPorts]. However, you have to tell cabal to include the <code>/opt/local/</code> directories when searching for external libraries. The following shell script does that by wrapping the <code>cabal</code> utility
  +
  +
> cat cabal-macports
  +
#!/bin/bash
  +
export CPPFLAGS=-I/opt/local/include
  +
export LDFLAGS=-L/opt/local/lib
  +
cabal $@ --extra-include-dirs=/opt/local/include \
  +
--extra-lib-dirs=/opt/local/lib
  +
  +
> cabal-macports install foobar
   
 
== Editors with Haskell support ==
 
== Editors with Haskell support ==
Line 33: Line 65:
   
 
* [http://aquamacs.org/ AquaMacs], a graphical Emacs version
 
* [http://aquamacs.org/ AquaMacs], a graphical Emacs version
* [http://eclipsefp.sourceforge.net/ Eclipse] with the [http://eclipsefp.sourceforge.net/ EclipseFP] plugin
+
* [http://eclipsefp.sourceforge.net/ Eclipse] with the [[EclipseFP]] plugin. See [[EclipseOn_Mac_OS_X]]
 
* [http://www.gnu.org/software/emacs/ Emacs], is installed on every Mac
 
* [http://www.gnu.org/software/emacs/ Emacs], is installed on every Mac
 
* [http://leksah.org/ Leksah]
 
* [http://leksah.org/ Leksah]
 
* [http://code.google.com/p/macvim/ MacVim], a graphical Vim version
 
* [http://code.google.com/p/macvim/ MacVim], a graphical Vim version
  +
* [https://github.com/textmate/textmate Textmate 2], open source incarnation of TextMate 1.
 
* [http://www.vim.org/ Vim], is installed on every Mac
 
* [http://www.vim.org/ Vim], is installed on every Mac
 
* [http://haskell.org/haskellwiki/Yi Yi] (written in Haskell itself!), is available through cabal-install
 
* [http://haskell.org/haskellwiki/Yi Yi] (written in Haskell itself!), is available through cabal-install
Line 50: Line 83:
 
[[Image:TextMate.png]]
 
[[Image:TextMate.png]]
   
and [http://tuppis.com/smultron/ Smultron]:
+
[http://tuppis.com/smultron/ Smultron]:
   
 
[[Image:Smultron.png]]
 
[[Image:Smultron.png]]
  +
  +
and [http://www.sublimetext.com/ Sublime Text 2]:
  +
[[Image:SubilmeText2.png]]
   
 
TextEdit is Mac's default text editor, a very basic editor that works fine for most uses, you must however be careful to put it into plain text mode using the Format menu.
 
TextEdit is Mac's default text editor, a very basic editor that works fine for most uses, you must however be careful to put it into plain text mode using the Format menu.
Line 62: Line 98:
 
== Links ==
 
== Links ==
 
* [[Using Haskell in an Xcode Cocoa project]]; a description of how to add a Haskell module (callable from C) to an Xcode/Cocoa/Interface builder project on your Mac.
 
* [[Using Haskell in an Xcode Cocoa project]]; a description of how to add a Haskell module (callable from C) to an Xcode/Cocoa/Interface builder project on your Mac.
+
* [[Mac OS X Common Installation Paths]]: an effort to standardize where things go on a Mac OS X installation
 
[[Category:OS]]
 
[[Category:OS]]

Revision as of 13:59, 3 December 2012

There is also now the Mac OS X Strike Force that aims to improve using Haskell on OS X.

Contents

1 The Haskell Platform

There are Mac OS X installers of the full Haskell Platform development environment. We recommend it:

button-100.png

2 GHC

2.1 Important notes

To get the most out of your GHC environment, you should add '~/Library/Haskell/bin' to your PATH environment variable before the path where you have GHC installed. This will allow you to get and use cabal-updates, as well as other programs shipped with GHC like hsc2hs.

In your ~/.profile, add the line:

export PATH=$HOME/Library/Haskell/bin:$PATH

2.2 Mac OS X 10.5 (Leopard)

To install GHC on Mac OS X 10.5 (Leopard), there are the following options:

2.3 Mac OS X 10.6 (Snow Leopard) and 10.7 (Lion)

To uninstall ghc call: sudo uninstall-hs

2.4 Xcode 4.1

GHC needs Xcode to be installed so it has access to the bintools, headers, and link libraries of the platform. The later two are provided by the SDK that comes as part of Xcode. GHC 7.0.2 is compiled against the 10.5 SDK. Xcode 4.1 no longer ships with it. ghci will work, but linking and some compiles with <ghc> will not. To make those work you need a copy of the 10.5 SDK. You can get this one several ways:

  • Before you install Xcode 4.1, if you have Xcode 3.2 installed, do one of the following:
    • Move it aside (renaming /Developer to /Xcode3.2)
    • Move just the sdk aside (moving /Developer/SDKs/MacOSX10.5.sdk to, say, /ExtraSDKs/MacOSX10.5.sdk)
    • Move just the sdk aside, install Xcode 4.1, then move it back into the /Developer/SDKs directory.
  • If you don't have Xcode 3.2, then you can download it from the Apple Developer site, and install it in a location other than "/Developer". If you have already installed Xcode 4.1 be sure that you customized the install and don't install the "System Tools" or "UNIX Development" packages.

Building via GHC:

ghc --make -I{loc}/MacOSX10.5.sdk/usr/include/ -L{loc}/MacOSX10.5.sdk/usr/lib

Building via cabal:

cabal --extra-include-dirs={loc}/MacOSX10.5.sdk/usr/include/ --extra-lib-dirs={loc}/MacOSX10.5.sdk/usr/lib

Replace {loc} with wherever you put the SDK.

3 HUGS


4 Installing libraries with external C bindings

Haskell libraries are installed with the cabal command line tool.

Some libraries depend on external C libraries, which are best installed with MacPorts. However, you have to tell cabal to include the /opt/local/ directories when searching for external libraries. The following shell script does that by wrapping the cabal utility

   > cat cabal-macports
   #!/bin/bash
   export CPPFLAGS=-I/opt/local/include
   export LDFLAGS=-L/opt/local/lib
   cabal $@ --extra-include-dirs=/opt/local/include \
            --extra-lib-dirs=/opt/local/lib
   > cabal-macports install foobar

5 Editors with Haskell support

5.1 Open Source

5.2 Commercial

SubEthaEdit:

SubEthaEdit.png

TextMate:

TextMate.png

Smultron:

Smultron.png

and Sublime Text 2: SubilmeText2.png

TextEdit is Mac's default text editor, a very basic editor that works fine for most uses, you must however be careful to put it into plain text mode using the Format menu.

6 Shipping Installable Haskell Applications

  • mkbndl builds installable Mac OSX applications from your Haskell project.

7 Links