December 18, 2014
Hot Topics:

Getting Functional with F#

  • November 14, 2008
  • By Jani Järvinen
  • Send Email »
  • More Articles »

What's more, you also can use F# interactively, just like a PowerShell prompt, for example. The interactive version of F# is very useful for quick prototyping, and is available both as a standalone command-line version and integrated into the Visual Studio 2008 IDE. The command-line version is named fsi.exe (see Figure 2).



Click here for a larger image.

Figure 2: F# can also be accessed interactively from the command line. A command-line compiler is also available.

Inside the Visual Studio IDE, you can open the interactive F# interpreter by using the View/Other Windows/F# Interactive menu command, or by pressing Ctrl+Alt+F. Naturally, you must install the F# installation package first for this to work (see Figure 3). To quit the console in the command-line version, type "#quit;;". Yes, two semicolons are needed; this is the standard statement separator.



Click here for a larger image.

Figure 3: Integrating F# with Visual Studio brings new menu commands to the IDE.

Currently, the overall Visual Studio integration is useful, but not yet fully ready. For example, you cannot start a WPF or web application project with F#. Instead, you currently have to use code-only files without any visual designers. In addition, basic F# code files (ones with the .fs file extension) look very plain: they just have the "#light" directive, which enables the so-called lightweight mode. Below that line, you would write your own code.

F# allows you to separate your code into modules and separate .fs code files to enable code reuse (see Figure 4). However, with this CTP version, it appears that the file that actually gets executed first is dependent on the order of which the code files are added to the project.



Click here for a larger image.

Figure 4: Starting a new or adding a new F# module begins with the New Project dialog box.

That is, the order the .fs files are referenced in the .fsproj XML project file is used. You can use Visual Studio's Solution Explorer popup menu commands to move items up and down. Luckily, this only affects modules that do not reference each other.





Page 3 of 4



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Sitemap | Contact Us

Rocket Fuel