Using F# interactive
Just a quick post on how to get the best out of F# Interactive
What is F# interactive?
That's a dang good question! Well you can think of F# interactive as being a console application that you type stuff into and its evaluated and based on what you type in the response varies - you may get something back saying "hey you just defined something of type int", or maybe something that is a function call, and here is it's returned data as a result of running that function.
Although not the same if you have used Hugs then you will be pretty well suited for F# interactive.
How do I get it?
Install the latest build of the F# compiler from the MSR site here, the installer will go ahead and install a Visual Studio add-in. The add-in is basically a window that you can activate within VS by going to Tools -> Add-In Manager, then from there selecting F# Interactive.
Single screen? Dual screen?
You can use the window within VS as something you choose to appear or disappear - which is ok but if like me you like code space to maximized then this can be a little restricting.
Instead I drag this window out onto my 2nd monitor so it's always visible - obviously if you don't have a 2nd monitor this is no use to you but if you do then you will learn to love it!
Actually using F# interactive
So, we've talked about it now lets use it! Go ahead an write some F# statement and then select the statement(s) that you want to execute and then hit Ctrl+Return and F# interactive will register your input via some textual feedback, e.g.
#light
open System
let x = 6
Console.WriteLine(x)
If you select each line of the code above then hit Ctrl+Return then you will see the following output:
I'm not going to run into this now, but you can see that the type of x is inferred from its value to be an int, and then the method call to System.Console.WriteLine(...).
Do you expect me to make my users run my F# code like this?
No. F# interactive is primarily a learning and experimentation aid - if you want to deploy something in an application then do so as some managed assembly. Using F# interactive allows you to step through the execution of code which is very useful.