Monday, November 22, 2010

F# in MonoDevelop on Mac OS X

In the article "F# in MonoDevelop and cross-platform web sites & screencasts", there are the instruction for installing F# in MonoDevelop on Linux. But someone ( of course, me too ) want to use this on Mac OS X and that instruction not suitable for on Mac OS X. So I introduce in this post.

0. Install F#

see also in this post.

1. Set FSHARP_COMPILER_BIN

$ vi ~/.profile.local and edit like below:
FSHARP_COMPILER_BIN="/Library/Frameworks/Mono.framework/Versions/Current/lib/fsharp/bin"
And re-login or restart.

2. Download "Additional scripts and tools only"

Download "Additional scripts and tools only" fsharp-bonus.tgz from here.

3. Install "Additional scripts and tools only"

$ cd /Library/Frameworks/Mono.framework/Versions/Current/lib/fsharp
$ sudo tar -zxvf /Path/To/fsharp-bonus.tgz
After above, patch below to the created file install-bonus.sh.
66,69c66,70
<
< export FSHARP_COMPILER_BIN=$FSHARPDIR
< echo "export FSHARP_COMPILER_BIN=$FSHARPDIR" > fsharp.sh
< mv fsharp.sh /etc/profile.d/
---
> if [[ ! "$OSTYPE" =~ "darwin" ]]; then
>     export FSHARP_COMPILER_BIN=$FSHARPDIR
>     echo "export FSHARP_COMPILER_BIN=$FSHARPDIR" > fsharp.sh
>     mv fsharp.sh /etc/profile.d/
> fi
72,73c73,77
<
< GTKPATH=/usr/lib/mono/gtk-sharp-2.0
---
> if [[ "$OSTYPE" =~ "darwin" ]]; then
>     GTKPATH=/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/gtk-sharp-2.0
> else
>     GTKPATH=/usr/lib/mono/gtk-sharp-2.0
> fi
81c85,89
< ATKPATH=/usr/lib/mono/gtk-sharp-2.0
---
> if [[ "$OSTYPE" =~ "darwin" ]]; then
>     ATKPATH=/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/gtk-sharp-2.0
> else
>     ATKPATH=/usr/lib/mono/gtk-sharp-2.0
> fi
89c97,101
< GLIBPATH=/usr/lib/mono/gtk-sharp-2.0
---
> if [[ "$OSTYPE" =~ "darwin" ]]; then
>     GLIBPATH=/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/gtk-sharp-2.0
> else
>     GLIBPATH=/usr/lib/mono/gtk-sharp-2.0
> fi
97c109,113
< GDKPATH=/usr/lib/mono/gtk-sharp-2.0
---
> if [[ "$OSTYPE" =~ "darwin" ]]; then
>     GDKPATH=/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/gtk-sharp-2.0
> else
>     GDKPATH=/usr/lib/mono/gtk-sharp-2.0
> fi
And then run this script:
sudo sh ./install-bonus.sh $FSHARP_COMPILER_BIN

4. Check fsharpc and fsharpi

$ which fsharpc
$ which fsharpi

5. Download and Install MonoDevelop

Download .dmg from here and install it.

6. Install F# add-in

Lanuch add-in manager:
Add new repository http://functional-variations.net/addin:
Check F# add-in and install:

7. Use F# add-in

Restart MonoDevelop and create my F# soluction:
At last, we can use F# add-in features:

No comments:

Post a Comment