Hi Yusaku,<div><br>On Tue, Feb 7, 2012 at 00:27, HASHIMOTO, Yusaku wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi, I wrote a simple shell function for switching GHC version on the<br>
system. It works only under Mac OSX, and only switch GHCs installed<br>
via .pkg installers. It's useful to experiment newer features without<br>
worrying breaking environment.<br>
<br>
GHC_BASE_DIR=/Library/Frameworks/GHC.framework/Versions/<br>
<br>
ghcs () {<br>
VERSION=$1<br>
sudo $GHC_BASE_DIR/$VERSION/Tools/create-links . /Library/Frameworks /<br>
}<br></blockquote><div><br></div><div>I have something quite similar, though mine depends on just one symbolic link, "Current". See the end of this email.</div><div><br></div><div>This approach also works with GHC installed from source. I use the following script to run 'configure' in the GHC source:</div>
<div><br></div><div><div>$ cat configure.mine </div><div>VERSION=7.4.1</div><div>./configure \</div><div> --prefix=/Library/Frameworks/GHC.framework/Versions/$VERSION/usr \</div><div> --with-gmp-libraries=/Library/Frameworks/GMP.framework \</div>
<div> --with-gmp-includes=/Library/Frameworks/GMP.framework/Headers</div></div><div><br></div><div>For me, the 'ghc-ver' script is useful since I'm often just want to quickly play with something in one version of GHC and not create a development environment. Other tools and approaches that have already been mentioned are also useful.</div>
<div><br></div><div>Regards,</div><div>Sean</div><div><br></div><div>----</div><div><br></div><div><div>$ cat ~/bin/ghc-ver </div><div>#!/bin/sh</div><div><br></div><div>ECHO="/bin/echo"</div><div><br></div><div>
PROGNAME=`basename $0`</div><div><br></div><div>if [ -z "$1" ];</div><div>then</div><div> $ECHO "Usage: $PROGNAME <version>"</div><div> $ECHO " $PROGNAME list"</div><div> exit 1</div>
<div>fi</div><div><br></div><div>VERSIONS_DIR="/Library/Frameworks/GHC.framework/Versions"</div><div><br></div><div>if [ "$1" = "list" ];</div><div>then</div><div> /usr/bin/find $VERSIONS_DIR -type d -depth 1 | xargs basename</div>
<div> exit 0</div><div>fi</div><div><br></div><div>CHOSEN_DIR="$VERSIONS_DIR/$1"</div><div><br></div><div>$ECHO -n "Checking for $CHOSEN_DIR ... "</div><div><br></div><div>if [ -d "$CHOSEN_DIR" ];</div>
<div>then</div><div> rm $VERSIONS_DIR/Current</div><div> ln -sf $CHOSEN_DIR $VERSIONS_DIR/Current</div><div> $ECHO "Success!"</div><div>else</div><div> $ECHO "Not found!"</div><div>fi</div><div><br>
</div><div>ghc --version</div></div><div><br></div><div><div>$ ls -l /usr/bin/ghc # as well as ghci, ghc-pkg, etc.</div></div><div>lrwxr-xr-x [...] /usr/bin/ghc -> /Library/Frameworks/GHC.framework/Versions/Current/usr/bin/ghc</div>
</div></div>