Personal tools

Mac OS X

From HaskellWiki

(Difference between revisions)
Jump to: navigation, search
(Added notes about putting .cabal/bin in your PATH)
(HUGS)
Line 48: Line 48:
   
 
* 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 ==

Revision as of 09:21, 14 March 2010

Contents

1 GHC

1.1 Important notes

To get the most out of your GHC environment, you should '~/.cabal/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 you ~/.profile, add the line:

export PATH="~/.cabal/bin:$PATH";


1.2 Mac OS X 10.5 (Leopard)

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

1.3 Mac OS X 10.6 (Snow Leopard)

Mac OS X 10.6.x (Snow Leopard) works with GHC, after you apply a simple patch. The problem is that GHC generates 32bit code, but gcc on Snow Leopard defaults to 64bit code on machines with processors that support it. The patch simply tells GHC to tell gcc to work in 32bit:

  • Install the Haskell Platform
  • Open /Library/Frameworks/GHC.framework/Versions/Current/usr/bin/ghc-6.10.4 in a text editor
  • Insert -optc-m32 -opta-m32 -optl-m32 just before the last parameter.


The last line in that file is rather long, and should now end like -dynload wrapped -optc-m32 -opta-m32 -optl-m32 ${1+"$@"}


Don't be tempted to just put an edited local copy of the script in ~/bin/ghc, or edit all the various GHC files in /usr/bin. There is a maze of twisty symlinks that all eventually lead to the above script, and fixing just it is far simpler.

See also Haskell on Snow Leopard.

Many packages need hsc2hs. To make it work correctly you need similar hackery:

  • Open /usr/bin/hsc2hs
  • Insert --cflag="-m32" --lflag="-m32" before $tflag

Affected packages include things like zlib and mmap. Building them on Snow Leopard without the above trick leads to nasty bugs in packages depending on them (including darcs). For darcs built on an affected system symptoms include messages like "incompatible zlib version" and "memory allocation failed".

To uninstall ghc call:

sudo /Library/Frameworks/GHC.framework/Tools/Uninstaller

2 HUGS


3 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

4 Editors with Haskell support

4.1 Open Source

  • AquaMacs, a graphical Emacs version
  • Eclipse with the EclipseFP plugin
  • Emacs, is installed on every Mac
  • Leksah
  • MacVim, a graphical Vim version
  • Vim, is installed on every Mac
  • Yi (written in Haskell itself!), is available through cabal-install

4.2 Commercial

SubEthaEdit:

SubEthaEdit.png

TextMate:

TextMate.png

and Smultron:

Smultron.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.

5 Shipping Installable Haskell Applications

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

6 Links