Jun 26

F# Hello Winform

The following is a hello world WinForms example:

    open System
    open System.Windows.Forms

    let form = new Form()
    do form.Width  

If you save the above as


then assuming fsc is in your path, you can compile and run it as follows:

    cd devsrc
    fsc devsrchelloforms.fs
Jun 26

F# Hello World

The following steps guide you to compiling your first program, with F# version with .NET 2.0.

  • From Add/Remove programs, uninstall any previous F# installs.
  • Download F# and save the zip file locally.
  • Extract the files to a temporary location:
    cd tempFSharp-
  • Run the .msi installer from that directory. This requires .NET 2.0.

    Note, if you have Visual Studio, the installer will run devenv /setup which takes some moments.

  • Add the F# bin directory to your path:
    set PATH=c:Program FilesFSharp-;%PATH%
  • fsc is the command line compiler. You can list the command line options as follows:
    fsc -help
  • Create a source directory.
    mkdir devsrc
  • Create a file \dev\src\hello.fs containing:
    printf "Hello World!n"
  • Compile it to give a hello.exe which you can run.
    cd devsrc
    fsc hello.fs