If you use Visual Studio 2008 (including the freely available Visual Studio 2008 Shell), you can use 'F# Interactive' as a tool window!
To start the session, go to the View -> Other Windows and select 'F# Interactive'. You can also start a session simply using Alt-Return in an F# source document, or using the shortcut Ctrl+Alt+F.
You create a script file using File -> New File -> Script -> F# Script File.
The normal mode of operation is to edit an F# script file and send fragments for execution in the tool window. In this mode, your fragments are typechecked as you type, and you are actively working towards a completed file that can act as the finished product of your explorative programming. The tool window is then just used for displaying data.
In the script file, you should use #r and #I to reference assemblies and augment your assembly include path.
The session is global to the instance of Visual Studio and text can be sent from any F# source code file (.fs, .fsi, .fsx, .ml, .mli). Use the Alt-Return combination to evaluate selected text. For example, highlight printfn "Hello World" and use this key combination - the code will then execute.
The F# Interactive session executes only those code fragments you direct it to. If you select a fragment from half-way through your script, earlier portions of the script will not be executed implicitly.
When sending text from a file, file names are resolved relative to the scripts containing the reference. Visual F# Interactive sets the line and directory context of the session each time an entry is sent from Visual Studio, though it doesn't adjust the value of System.Environment.CurrentDirectory. It can be useful to add
System.Environment.CurrentDirectory <- __SOURCE_DIRECTORY__
to your script. __SOURCE_DIRECTORY can be used in any F# source file and is expanded to the directory containing the file.
Although scripts can be authored without a project, it can be useful to create an F# Project to hold a group of related scripts. You can do this with New Project or by making a copy of one of the projects in the F# Samples directory. You can also use #load to load both signature and implementation files as if they have been compiled as compilation units by the command-line compiler.
In the tool window, #quit;; will quit and Ctrl+C will cancel execution. The context menu in the tool window includes "Reset Session" and "Cancel Evaluation" commands. If you do type into the tool window, history is available with the up/down arrows.
To troubleshoot, see README-fsharp.html
Please contact fsbugs@microsoft.com with feedback on this documentation.