Difference between revisions of "Mac OS X"

From HaskellWiki
Jump to navigation Jump to search
(→‎Mac OS X 10.5 (Leopard): http://hackage.haskell.org/platform/)
(Vanilla emacs is graphical)
 
(47 intermediate revisions by 21 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]
  +
  +
== [http://haskellformac.com Haskell for Mac (IDE)] ==
  +
  +
[http://haskellformac.com Haskell for Mac] is an easy-to-use integrated programming environment for Haskell on OS X. It is a one-click install of a complete Haskell system, including Haskell compiler, editor, many libraries, and a novel form of interactive <em>Haskell playgrounds</em>. Haskell playgrounds support exploration and experimentation with code. They are convenient to learn functional programming, prototype Haskell code, interactively visualize data, and to create interactive animations.
  +
  +
Features include the following:
  +
* Built-in Haskell editor with customisable themes, or you can use a separate text editor.
  +
* Interactive Haskell playgrounds evaluate your code as you type.
  +
* Easy to explore type information and to observe the behaviour of you program as you change it.
  +
* Playground results can be text or images produced by the Rasterific, Diagrams, and Chart packages.
  +
* Add code and multimedia files to a Haskell project with drag'n'drop.
  +
* Haskell binding to Apple's 2D animation and games framework SpriteKit.
  +
* Autosaving and automatic project versioning.
  +
  +
Haskell for Mac supports OS X Yosemite or above.
  +
 
== 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.9 (Mavericks), Mac OS X 10.8 (Mountain Lion) and Xcode 5 ===
  +
  +
Both Mountain Lion and Mavericks support and now use XCode 5, which no longer provides GCC, only Clang.
  +
  +
This should not be problem for GHC 7.8 and newer, but
  +
If using GHC 7.6.* or older, one of several work arounds is needed!
  +
  +
The workaround that the Haskell Platform maintainers are supporting can be found [http://www.haskell.org/pipermail/haskell-cafe/2013-October/111174.html here]. That work around along with [http://justtesting.org/post/64947952690/the-glasgow-haskell-compiler-ghc-on-os-x-10-9 this one] work with only the system provided compilers.
  +
  +
However, if you are still encountering usual bugs, the GCC based directions [https://gist.github.com/cartazio/7131371 here] may work out better.
   
 
=== Mac OS X 10.5 (Leopard) ===
 
=== Mac OS X 10.5 (Leopard) ===
   
To install GHC on Mac OS X, there are the following options:
+
To install GHC on Mac OS X 10.5 (Leopard), there are the following options:
* [http://hackage.haskell.org/platform/ Haskell Platform]
+
* install the [http://hackage.haskell.org/platform/ Haskell Platform]
  +
* install [http://www.macports.org MacPort]'s [http://trac.macports.org/browser/trunk/dports/lang/ghc/Portfile ghc] package
* [http://haskell.org/ghc/download_ghc_6_10_4.html#binaries Standalone installer].
 
** You need to have [http://developer.apple.com/technology/Xcode.html Xcode 3.0] installed. If you do not have Xcode, you can install it from the installation DVD you got with you Mac or download it for free from [http://developer.apple.com/ Apple Developer Connection].
 
* [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) ===
   
  +
* Install the [http://hackage.haskell.org/platform/ Haskell Platform]
* [http://obvioushints.blogspot.com/2009/09/running-haskell-ghc-on-snow-leopard.html Running GHC on Snow Leopard]
 
** as of 2009-09-08 [http://www.macports.org MacPorts]'s package ghc is not yet supported on Mac OS X 10.6.x (SnowLeopard)
 
   
  +
To uninstall ghc call:
=== MacPorts ===
 
  +
<code>
  +
sudo uninstall-hs
  +
</code>
   
  +
=== Xcode 4.1 ===
[http://www.macports.org MacPorts] contains a Portfile for [http://trac.macports.org/browser/trunk/dports/lang/ghc/Portfile GHC]. Using MacPorts to install GHC will take a while as your computer will compile all the source files itself. In most cases, you're better off installing GHC through the standalone installer (see next section).
 
   
  +
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:
If you have MacPorts installed and haven't told it to selfupdate in a while, do that first:
 
   
  +
* Before you install Xcode 4.1, if you have Xcode 3.2 installed, do one of the following:
$ sudo port selfupdate
 
  +
** Move it aside (renaming <tt>/Developer</tt> to <tt>/Xcode3.2</tt>)
  +
** 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:
This will take up to a minute, so be patient. It tells MacPorts to retrieve the latest package information from its servers. Next, install GHC:
 
  +
ghc --make -I{loc}/MacOSX10.5.sdk/usr/include/ -L{loc}/MacOSX10.5.sdk/usr/lib
   
  +
Building via cabal:
$ sudo port install ghc
 
  +
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.
MacPorts will first download and install any dependencies that are needed to install GHC; then it will download, build and install GHC itself. A point of caution however. MacPorts also provides GHC packages. If these are installed and then GHC is upgraded the packages need to be uninstalled and reinstalled, or they will not register properly with the upgraded GHC.
 
   
 
== HUGS ==
 
== HUGS ==
   
There is a [http://www.macports.org MacPorts] package for Hugs (under the name [http://trac.macports.org/browser/trunk/dports/lang/hugs98/Portfile hugs98]).
+
* install [http://www.macports.org MacPort]'s [http://trac.macports.org/browser/trunk/dports/lang/hugs98/Portfile hugs98] package.
   
  +
== Editors ==
 
  +
== 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 ==
   
 
=== Open Source ===
 
=== Open Source ===
   
* [http://aquamacs.org/ AquaMacs], a graphical Emacs version
+
* [http://aquamacs.org/ AquaMacs] or [http://emacsforosx.com EmacsForOSX], Emacs for macOS
  +
* [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]
  +
* [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 52: Line 119:
 
[[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 132:
 
* [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/mkbndl mkbndl] builds installable Mac OSX applications from your Haskell project.
 
* [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/mkbndl mkbndl] builds installable Mac OSX applications from your Haskell project.
   
  +
== 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.
  +
* [[Mac OS X Common Installation Paths]]: an effort to standardize where things go on a Mac OS X installation
 
[[Category:OS]]
 
[[Category:OS]]

Latest revision as of 15:32, 26 December 2022

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:

button-100.png

Haskell for Mac (IDE)

Haskell for Mac is an easy-to-use integrated programming environment for Haskell on OS X. It is a one-click install of a complete Haskell system, including Haskell compiler, editor, many libraries, and a novel form of interactive Haskell playgrounds. Haskell playgrounds support exploration and experimentation with code. They are convenient to learn functional programming, prototype Haskell code, interactively visualize data, and to create interactive animations.

Features include the following:

  • Built-in Haskell editor with customisable themes, or you can use a separate text editor.
  • Interactive Haskell playgrounds evaluate your code as you type.
  • Easy to explore type information and to observe the behaviour of you program as you change it.
  • Playground results can be text or images produced by the Rasterific, Diagrams, and Chart packages.
  • Add code and multimedia files to a Haskell project with drag'n'drop.
  • Haskell binding to Apple's 2D animation and games framework SpriteKit.
  • Autosaving and automatic project versioning.

Haskell for Mac supports OS X Yosemite or above.

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:

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

Mac OS X 10.9 (Mavericks), Mac OS X 10.8 (Mountain Lion) and Xcode 5

Both Mountain Lion and Mavericks support and now use XCode 5, which no longer provides GCC, only Clang.

This should not be problem for GHC 7.8 and newer, but
If using GHC 7.6.*  or older, one of several work arounds is needed!

The workaround that the Haskell Platform maintainers are supporting can be found here. That work around along with this one work with only the system provided compilers.

However, if you are still encountering usual bugs, the GCC based directions here may work out better.

Mac OS X 10.5 (Leopard)

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

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

To uninstall ghc call: sudo uninstall-hs

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.

HUGS


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

Editors with Haskell support

Open Source

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.

Shipping Installable Haskell Applications

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

Links