Setting Up Your Environment
Prerequisites: Installing F#
Editor
- Visual Studio Code with the Ionide-fsharp extension — free, cross-platform, and the most popular choice. It gives autocompletion, inline type hints, error checking, and "send to F# Interactive".
- JetBrains Rider — a full .NET IDE with excellent F# support.
- Visual Studio (Windows) — install the ".NET desktop development" workload, which includes F#.
F# Interactive (the REPL)
Run dotnet fsi to get an interactive prompt. End each input with ;;
and F# prints the value and its type:
$ dotnet fsi
Microsoft (R) F# Interactive version 15.2.401.0 for F# 10.0
Copyright (c) Microsoft Corporation. All Rights Reserved.
For help type #help;;
> 1 + 2;;
val it: int = 3
> let square x = x * x;;
val square: x: int -> int
> square 7;;
val it: int = 49
> #quit;;
it is the value of the last expression. square: x: int -> int means
"a function taking an int called x and returning an int" — you'll
read signatures like this constantly.
Scripts and projects
- Scripts (
.fsx) run directly:dotnet fsi hello.fsx. Most examples in this course are scripts. - Projects (
.fsproj) are for applications and libraries:dotnet new console -lang F#creates one,dotnet runruns it.
Formatting
Fantomas is the standard F# code formatter; Ionide and Rider can run it on save.