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&#39;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, &quot;Current&quot;. 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 &#39;configure&#39; 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 &#39;ghc-ver&#39; script is useful since I&#39;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=&quot;/bin/echo&quot;</div><div><br></div><div>

PROGNAME=`basename $0`</div><div><br></div><div>if [ -z &quot;$1&quot; ];</div><div>then</div><div>  $ECHO &quot;Usage: $PROGNAME &lt;version&gt;&quot;</div><div>  $ECHO &quot;       $PROGNAME list&quot;</div><div>  exit 1</div>

<div>fi</div><div><br></div><div>VERSIONS_DIR=&quot;/Library/Frameworks/GHC.framework/Versions&quot;</div><div><br></div><div>if [ &quot;$1&quot; = &quot;list&quot; ];</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=&quot;$VERSIONS_DIR/$1&quot;</div><div><br></div><div>$ECHO -n &quot;Checking for $CHOSEN_DIR ... &quot;</div><div><br></div><div>if [ -d &quot;$CHOSEN_DIR&quot; ];</div>

<div>then</div><div>  rm $VERSIONS_DIR/Current</div><div>  ln -sf $CHOSEN_DIR $VERSIONS_DIR/Current</div><div>  $ECHO &quot;Success!&quot;</div><div>else</div><div>  $ECHO &quot;Not found!&quot;</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 -&gt; /Library/Frameworks/GHC.framework/Versions/Current/usr/bin/ghc</div>

</div></div>