Simplifying bash & repl Use With F#

That prompt… let’s get F# so that we can compile and run a file in about a zillionth of a second from the repl.

First I setup a bash script that would be used to compile and then run the file. I created the file and simply named it “fs”. Inside the file I wrote the following script.

[sourcecode language=”bash”]
echo "Compiling F#" + $1
fsharpc "$1.fs"
mono "$1.exe"
echo "Running Executable" + $1
[/sourcecode]

I put that in my scripts folder that I have added to my path in my ~/.bash_profile (or bashrc depending on what you’re rolling with).

[sourcecode language=”bash”]
export PATH="$PATH:~/Codez/scripts"
[/sourcecode]

So now I have the ability to type in the following command and filename and the compile and the executable will be run. It makes for much easier repl usage.

[sourcecode language=”bash”]
fs theFileNameGoesHere
[/sourcecode]

Got any tips or tricks to running F# somewhere besides Windows? Let me know and I’ll be sure to give you a shout out on Twitter and whenever I’m giving a presentation on hacking F# without Windows.

1 Comment

Comments are closed.