F# Training
F# Training
F# Training
  • Presentation
  • Fundamentals
    • Introduction
    • Syntax
      • Bases
      • Functions
      • Rules
      • Exceptions
    • First concepts
    • πŸ”Quiz
  • Functions
    • Signature
    • Concepts
    • Syntax
    • Standard functions
    • Operators
    • Addendum
    • πŸ”Quiz
    • πŸ“œSummary
  • Types
    • Overview
    • Tuples
    • Records
    • Unions
    • Enums
    • Anonymous records
    • Value types
    • πŸ“œRecap
    • Addendum
  • Monadic types
    • Intro
    • Option type
    • Result type
    • Smart constructor
    • πŸš€Computation expression (CE)
    • πŸš€CE theoretical basements
    • πŸ“œRecap
  • Pattern matching
    • Patterns
    • Match expression
    • Active patterns
    • πŸš€Fold function
    • πŸ“œRecap
    • πŸ•ΉοΈExercises
  • Collections
    • Overview
    • Types
    • Common functions
    • Dedicated functions
    • πŸ”Quiz
    • πŸ“œRecap
  • Asynchronous programming
    • Asynchronous workflow
    • Interop with .NET TPL
    • πŸ“œRecap
  • Module and Namespace
    • Overview
    • Namespace
    • Module
    • πŸ”Quiz
    • πŸ“œRecap
  • Object-oriented
    • Introduction
    • Members
    • Type extensions
    • Class, Struct
    • Interface
    • Object expression
    • Recommendations
Powered by GitBook
On this page
  • Key points
  • History
  • Editors / IDE
  • Fβ™― interactive (FSI)
  • File types
  • Standalone file
  • Project files
  • Fβ™― Project

Was this helpful?

Edit on GitHub
  1. Fundamentals

Introduction

Key points

Microsoft language family on the .NET platform

  • Designer: Don Syme @ Microsoft Research

  • ≃ OCaml implementation for .NET

  • ≃ Inspired by Haskell (Version 1.0 in 1990)

  • dotnet new -lang Fβ™―

  • Interoperability between Cβ™― and Fβ™― projects/assemblies

Multi-paradigm language Functional-first and very concise

Whereas Cβ™― is imperative/objective-oriented-first and rather verbose (even if it's inspired by Fβ™― to become more succinct and functional)

History

Date
Cβ™―
Fβ™―
.NET
Visual Studio

2002

Cβ™― 1.0

.NET Framework 1.0

VS .NET 2002

2005

Cβ™― 2.0

Fβ™― 1.x

.NET Framework ?.?

VS 2005

2007

Cβ™― 3.0

.NET Framework 3.5

VS 2008

2010

Cβ™― 4.0

Fβ™― 2.0

.NET Framework 4

VS 2010

...

...

...

...

...

2019

Cβ™― 8.0

Fβ™― 4.7

.NET Core 3.x

VS 2019

2020

Cβ™― 9.0

Fβ™― 5.0

.NET 5.0

VS 2019

...

...

...

...

...

2024

Cβ™― 13.0

Fβ™― 9.0

.NET 9.0

VS 2022

Editors / IDE

  • Visual Studio / Rider β†’ ☝ Less refactoring capabilities than for Cβ™―

Fβ™― interactive (FSI)

  • REPL available in VS, Rider, vscode + dotnet fsi

  • Usage : instantly test a snippet

    • πŸ’‘ In the FSI console, enter ;; at the end of an expression to evaluate it

Example from vscode with ionide:

πŸ’‘ In the FSI console, enter ;; at the end of an expression to evaluate it

☝️ Notes:

  • Cβ™― interactive is more recent (VS 2015 Update 1). The FSI was there from the get go.

File types

4 file types: .fs, .fsi, .fsx, .fsproj

⚠️ Single language : for Fβ™― only

Standalone file

  • Script file .fsx

    • Executable (hence the final x) using the FSI

    • Independent but can reference other files, DLLs, NuGet packages

Project files

  • In Cβ™― : .sln contains .csproj projects that contains .cs files

  • In Fβ™― : .sln contains .fsproj projects that contains .fs(i) code files

πŸ’‘ Easy Interop = Combine both .csproj and .fsproj projects in the same .sln

.fsi are signature files (i for interface)

  • Associated with a .fs file of the same name

  • Optional and rather rare in codebases

  • Usages

    • Reinforces encapsulation (like .h in C)

    • Separate long documentation (xml-doc)

Fβ™― Project

Creation in the IDE or using the CLI dotnet:

  • dotnet new -l : list supported project types

  • dotnet new console --language Fβ™― -o MyFSharpApp

    • CrΓ©ation of a console project named MyFSharpApp

    • --language Fβ™― is key to specify the language, by default in C#

  • dotnet build : to build the project

  • dotnet run : to build the project and run the underlying executable

PreviousPresentationNextSyntax

Last updated 1 month ago

Was this helpful?

πŸ”— Versions details:

VsCode + β†’ ☝ More a boosted text editor than a full IDE β†’ ☝ Permissive: does not always report all compilation errors β†’ πŸ”— by Compositional IT

Try Fβ™―: β†’ Online with some examples

Alternative worth trying, also working for C#:

More info :

https://learn.microsoft.com/en-us/dotnet/fsharp/whats-new/
Ionide
Fantastic Fβ™― and Azure Developer Extensions for VSCode
https://try.fsharp.org/
REPL
LINQPad
MSDN
FSI: Send Selection