Inside F#

Brian's thoughts on F# and .NET

Welcome to the F# CTP project system: project templates

Posted by Brian on August 29, 2008

As you may have already heard, the F# CTP has been released!  Here is the release announcement.  I’ll continue describing the F# project system, but now that the CTP is out, you can follow along on your own machine, rather than just having to soak in the teaser screenshots I posted in prior blog entries.  :)

Today’s blog entry describes the F# project templates.  Whereas the prior releases of F# came with only one project template, the CTP release has three.  Inside Visual Studio, do a "File>New>Project" and select the "Visual F#" node to see this:


(Aside: if you’re like me, and you still have a prior install of F# on your machine, the old project template will still appear in "Other Project Types > F# Projects" under "Project types".  So if you’re only seeing the old template after installing the CTP, make sure that you have selected the new "Visual F#" node and not the old "F# Projects" node:


Also, note that my screenshots today are from my computer at home, which has only the free Visual Studio 2008 Shell installed.  If you have a full version of Visual Studio, then you’ll also see other project types, such as "Visual C#", in the "New Project" dialog.)

There are three types of F# project templates in the F# CTP release; I’ll describe each in turn.

F# Application

The "F# Application" template is used to build an executable program (EXE).  It will start you with a single source code file, Program.fs.  Type in some code, and you can just build and run:


F# Library

The "F# Library" template is used to build a library (DLL), which you might later reference from another application (and that application might be written in F#, or C#, or whatever – see my previous blog entry on project references).  The "F# Library" template starts you off with two files: Module1.fs, an F# source code file that will be compiled into the library DLL, and Script.fsx, an F# script file which is not compiled into the library DLL.  I’ll talk more about F# script files in a future blog entry; briefly, scripts are one easy way to associate extra functionality (such as unit tests) with a particular project, without that functionality being compiled into the project.


F# Tutorial

The "F# Tutorial" template’s main purpose is to demonstrate some of the main features and syntax of the F# language with some sample code.  If you are relatively new to the language, reading the code in Tutorial.fs is one way to get a quick introduction to F#.  It’s also useful if you need a quick refresher to remember the syntax for a particular feature.  For instance, if I forget how to author a class that implements an interface, I can scroll down through the tutorial code and find:


There’s lots more to talk about with the new project system… more blog entries coming soon!  (If you have questions in the meantime, feel free to post them in comments on this blog, or to use the forums on the hub.)


4 Responses to “Welcome to the F# CTP project system: project templates”

  1. MichaelGG said

    Congratulations. This is so exciting; I hope to have F# integrated into our builds before the weekend ends. As a side note, are you running a dark Windows theme? I\’ve wanted this for so long, but could only get VS to go dark, making the contrast with other apps hurt to much. How did you do this? (You\’d have thought with all the Vista hype, they\’d somehow enable this, but, wow, they didn\’t.)

  2. Brian said

    No "theme", I just dislike bright white backgounds, so I set the default window background color in Windows to grey rather than white.  (On Windows XP, right click the desktop, "Properties", "Appearance" tab, "Advanced" button, click the background of the Active Window, and set the color.  On Vista it\’s similar, but the first couple steps are "Personalize" and "Window Color and Appearance".)

  3. Gaurav said

    Cool, I have been waiting for CTP release so long…
    Awesome, I m going to download …
    Also, One thing i like to see in future CTP is support for WinForms project in F# … ! Ofcourse , I know about other ways that i could use like create Form in C# and then refer through F# which is simple too.
    But i would like to see Designer that would generate Form code in F# style.

  4. Unknown said

    Its gr8 to see F# getting momentum..

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: