[Haskell-cafe] Ease of Haskell development on OS X?

Hans Aberg haberg at math.su.se
Fri Mar 20 17:02:05 EDT 2009


On 20 Mar 2009, at 21:05, David Leimbach wrote:

> > Since GHC is written in Haskell, do you need to have another Haskell
> > compiler installed before GHC 6.10.1 can be installed through  
> MacPorts?
>
> It bootstraps itself.
>
> ???  GHC does or MacPorts does.  My experience was that you needed  
> GHC to build GHC :-)

MacPort developers tweak sources into packages which can install by  
themselves. So one just types
   sudo port install ghc
and it does the rest. Here is info about ghc:
> $ port info ghc
> ghc 6.8.3, Revision 1, lang/ghc (Variants: universal, darwin_6,  
> darwin_7, darwin_8_powerpc, darwin_8_i386, darwin_9_powerpc,  
> darwin_9_i386, no_opengl)
> http://haskell.org/
>
> The Glasgow Haskell Compiler is a robust, fully-featured, optimising  
> compiler and interactive environment for Haskell 98, GHC compiles  
> Haskell to either native code or C. It implements numerous  
> experimental language extensions to Haskell 98, for example:  
> concurrency, a foreign language interface, multi-parameter type  
> classes, scoped type variables, existential and universal  
> quantification, unboxed types, exceptions, weak pointers, and so on.  
> GHC comes with a generational garbage collector, and a space and  
> time profiler.
>
> Library Dependencies: readline, gmp
> Runtime Dependencies: perl5.8
> Platforms: darwin
> Maintainers: gwright at macports.org

However, as someone needs to do the packaging, the versions tend to be  
older than from direct sources. So the latter is to be preferred, but  
the package manager does the package chasing for you (which is a  
problem with Gtk+ installed directly).

Therefore, as mentioned before, it might be best to install the GHC  
binaries and install libraries like Gtk+ from MacPorts. There is also  
Intel Gtk+ that binds directly to Aqua, the Mac OS X native GUI (for  
making native Mac OS X Applications):
   http://www.gtk-osx.org/

You need to set of environmental variables UNIX style, but there is a  
Mac OS X way, too (see below). In the traditional way, one must be  
aware of that the shell 'bash' (see 'man bash') reads different  
startup files when called as a login shell (as from the Terminal) and  
non-login-shell (as from X11 and xterm). For the former, one can put  
the stuff in .profile, and the latter .bashrc. To make things simple,  
one can put in .bashrc:
   source ~/.profile
thus reading .profile. In .profile, one might put something like the  
stuff at the bottom of this letter (which also adds support for the  
other package manager, as well admitting user binaries to be installed).

There is another, Mac OS X specific way (also see below): go to  
Terminal, and make a directory:
   cd
   mkdir .MacOSX
   cd .MacOSX
   touch environment.plist
   open -a Xcode environment.plist
The last command opens the file into the Xcode editor, which has a  
facility to create the special format for these files. Pne drawback of  
this method is the one has to log out and login again to set them.

This assumes you have installed Xcode, wither from the installation  
disk, or by signing up as a developer at http://developer.apple.com/

When working with files, it is convenient to set them so that they  
open in your favorite program. For that, I have found it convenient to  
install a System Preferences panel 'Default Apps' found at
   http://www.rubicode.com/Software/
I see now they have one for editing the environment.plist file.

If you come from a non-UNIX (POSIX) platform, then note that in order  
to work as root, it is most of the time sufficient to use (from an  
administrator account)
   sudo -s
The 'root' account is by default disabled (can be started from the  
Directory Utility). Also never edit in /usr/ outside /usr/local/, the  
other system directories, or /System/ as they belong to the system  
installation (Mac OS X user modified system files are out into / 
Library/, but often via some other program which does safety checks.)

   Hans Aberg


----
# Add to end of searchpath:
append_path()
{
   if ! eval test -z "\"\${$1##*:$2:*}\"" -o -z "\"\${$1%%*:$2}\"" -o - 
z "\"\${$1##$2:*}\"" -o -z "\"\${$1##$2}\"" ; then
     eval "$1=\$$1:$2"
   fi
}

# Add to beginning of searchpath:
prepend_path()
{
   if ! eval test -z "\"\${$1##*:$2:*}\"" -o -z "\"\${$1%%*:$2}\"" -o - 
z "\"\${$1##$2:*}\"" -o -z "\"\${$1##$2}\"" ; then
     eval "$1=$2:\$$1"
   fi
}

# Set system searchpaths:

# In the case a directory may exist (depending on the program) both  
with and without
# parent directory 'share/' (like in the cae of MANPATH and INFOPATH),  
the 'share/'
# version is put first, as it is what is used in /usr on Mac OS X  
FreeSD UNIX.
# The idea is that if a program is somehow adapted to this platform,  
the the stuff will
# be moved to the 'share/' variation, and should thus be ovverride the  
unadapted versions.

PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin
MANPATH=/usr/share/man:/usr/X11R6/man
INFOPATH=/usr/share/info
LIBPATH=/usr/lib:/usr/X11R6/lib

# Prepend Fink searchpaths:
test -r /sw/bin/init.sh && . /sw/bin/init.sh

# Prepend MacPorts (former DarwinPorts) searchpaths:
prepend_path PATH /opt/local/bin:/opt/local/sbin
prepend_path MANPATH /opt/local/share/man:/opt/local/man
prepend_path INFOPATH /opt/local/share/info:/opt/local/info
prepend_path LIBPATH /opt/local/lib

# Prepend MacTeX paths
prepend_path PATH /usr/texbin
prepend_path MANPATH /usr/local/texlive/2007/texmf/doc/man
prepend_path INFOPATH /usr/local/texlive/2007/texmf/doc/info

# Prepend /usr/local/ searchpaths:
prepend_path PATH /usr/local/bin:/usr/local/X11R6/bin
prepend_path MANPATH /usr/local/share/man:/usr/local/man
prepend_path INFOPATH /usr/local/share/info:/usr/local/info
prepend_path LIBPATH /usr/local/lib

# Prepend $HOME searchpaths:
prepend_path PATH $HOME/local/bin
prepend_path MANPATH $HOME/local/share/man:$HOME/local/man
prepend_path INFOPATH $HOME/local/share/info:$HOME/local/info
prepend_path LIBPATH $HOME/local/lib

# Export changed paths:
export PATH
export MANPATH
export INFOPATH
export LIBPATH
----



More information about the Haskell-Cafe mailing list